Changeset 374552ef in mainline


Ignore:
Timestamp:
2011-02-18T20:22:08Z (14 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
423e8c81, 6edc69a, fbf0589
Parents:
b6c7da6 (diff), b36e5de2 (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:

Merged removals of old API

Location:
uspace
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/uhci-hcd/iface.c

    rb6c7da6 r374552ef  
    164164        return EOK;
    165165}
    166 /*----------------------------------------------------------------------------*/
    167 static int control_write_setup(device_t *dev, usb_target_t target,
    168     size_t max_packet_size,
    169     void *data, size_t size,
    170     usbhc_iface_transfer_out_callback_t callback, void *arg)
    171 {
    172         dev_speed_t speed = FULL_SPEED;
    173166
    174         usb_log_warning("Using deprecated API %s.\n", __FUNCTION__);
    175         batch_t *batch = batch_get(dev, target, USB_TRANSFER_CONTROL,
    176             max_packet_size, speed, NULL, 0, data, size, NULL, callback, arg);
    177         if (!batch)
    178                 return ENOMEM;
    179         batch_control_setup_old(batch);
    180         return EOK;
    181 }
    182 /*----------------------------------------------------------------------------*/
    183 static int control_write_data(device_t *dev, usb_target_t target,
    184     size_t max_packet_size,
    185     void *data, size_t size,
    186     usbhc_iface_transfer_out_callback_t callback, void *arg)
    187 {
    188         dev_speed_t speed = FULL_SPEED;
    189167
    190         usb_log_warning("Using deprecated API %s.\n", __FUNCTION__);
    191         batch_t *batch = batch_get(dev, target, USB_TRANSFER_CONTROL,
    192             max_packet_size, speed, data, size, NULL, 0, NULL, callback, arg);
    193         if (!batch)
    194                 return ENOMEM;
    195         batch_control_write_data_old(batch);
    196         return EOK;
    197 }
    198 /*----------------------------------------------------------------------------*/
    199 static int control_write_status(device_t *dev, usb_target_t target,
    200     usbhc_iface_transfer_in_callback_t callback, void *arg)
    201 {
    202         size_t max_packet_size = 8;
    203         dev_speed_t speed = FULL_SPEED;
    204 
    205         usb_log_warning("Using deprecated API %s.\n", __FUNCTION__);
    206         batch_t *batch = batch_get(dev, target, USB_TRANSFER_CONTROL,
    207             max_packet_size, speed, NULL, 0, NULL, 0, callback, NULL, arg);
    208         if (!batch)
    209                 return ENOMEM;
    210         batch_control_write_status_old(batch);
    211         return EOK;
    212 }
    213 /*----------------------------------------------------------------------------*/
    214 static int control_read_setup(device_t *dev, usb_target_t target,
    215     size_t max_packet_size,
    216     void *data, size_t size,
    217     usbhc_iface_transfer_out_callback_t callback, void *arg)
    218 {
    219         dev_speed_t speed = FULL_SPEED;
    220 
    221         usb_log_warning("Using deprecated API %s.\n", __FUNCTION__);
    222         batch_t *batch = batch_get(dev, target, USB_TRANSFER_CONTROL,
    223             max_packet_size, speed, NULL, 0, data, size, NULL, callback, arg);
    224         if (!batch)
    225                 return ENOMEM;
    226         batch_control_setup_old(batch);
    227         return EOK;
    228 }
    229 /*----------------------------------------------------------------------------*/
    230 static int control_read_data(device_t *dev, usb_target_t target,
    231     size_t max_packet_size,
    232     void *data, size_t size,
    233     usbhc_iface_transfer_in_callback_t callback, void *arg)
    234 {
    235         dev_speed_t speed = FULL_SPEED;
    236 
    237         usb_log_warning("Using deprecated API %s.\n", __FUNCTION__);
    238         batch_t *batch = batch_get(dev, target, USB_TRANSFER_CONTROL,
    239             max_packet_size, speed, data, size, NULL, 0, callback, NULL, arg);
    240         if (!batch)
    241                 return ENOMEM;
    242         batch_control_read_data_old(batch);
    243         return EOK;
    244 }
    245 /*----------------------------------------------------------------------------*/
    246 static int control_read_status(device_t *dev, usb_target_t target,
    247     usbhc_iface_transfer_out_callback_t callback, void *arg)
    248 {
    249         size_t max_packet_size = 8;
    250         dev_speed_t speed = FULL_SPEED;
    251 
    252         usb_log_warning("Using deprecated API %s.\n", __FUNCTION__);
    253         batch_t *batch = batch_get(dev, target, USB_TRANSFER_CONTROL,
    254             max_packet_size, speed, NULL, 0, NULL, 0, NULL, callback, arg);
    255         if (!batch)
    256                 return ENOMEM;
    257         batch_control_read_status_old(batch);
    258         return EOK;
    259 }
    260168/*----------------------------------------------------------------------------*/
    261169usbhc_iface_t uhci_iface = {
     
    273181        .control_read = control_read,
    274182        .control_write = control_write,
    275 
    276         .control_write_setup = control_write_setup,
    277         .control_write_data = control_write_data,
    278         .control_write_status = control_write_status,
    279 
    280         .control_read_setup = control_read_setup,
    281         .control_read_data = control_read_data,
    282         .control_read_status = control_read_status
    283183};
    284184/**
  • uspace/drv/uhci-rhd/root_hub.c

    rb6c7da6 r374552ef  
    4747        assert(rh);
    4848        int ret;
    49         ret = usb_drv_find_hc(rh, &instance->hc_handle);
     49        ret = usb_hc_find(rh->handle, &instance->hc_handle);
    5050        usb_log_info("rh found(%d) hc handle: %d.\n", ret, instance->hc_handle);
    5151        if (ret != EOK) {
  • uspace/drv/usbhub/usbhub.c

    rb6c7da6 r374552ef  
    5050#include "usb/usb.h"
    5151
     52static int iface_get_hc_handle(device_t *device, devman_handle_t *handle)
     53{
     54        return usb_hc_find(device->handle, handle);
     55}
     56
    5257static usb_iface_t hub_usb_iface = {
    53         .get_hc_handle = usb_drv_find_hc
     58        .get_hc_handle = iface_get_hc_handle
    5459};
    5560
  • uspace/drv/vhc/connhost.c

    rb6c7da6 r374552ef  
    234234}
    235235
    236 static int enqueue_transfer_setup(device_t *dev,
    237     usb_target_t target, usb_transfer_type_t transfer_type,
    238     void *buffer, size_t size,
    239     usbhc_iface_transfer_out_callback_t callback, void *arg)
    240 {
    241         usb_log_debug2("Transfer SETUP [%d.%d (%s); %zu].\n",
    242             target.address, target.endpoint,
    243             usb_str_transfer_type(transfer_type),
    244             size);
    245 
    246         transfer_info_t *transfer
    247             = create_transfer_info(dev, USB_DIRECTION_OUT, arg);
    248         transfer->out_callback = callback;
    249 
    250         hc_add_transaction_to_device(true, target, transfer_type, buffer, size,
    251             universal_callback, transfer);
    252 
    253         return EOK;
    254 }
    255 
    256236static int enqueue_transfer_in(device_t *dev,
    257237    usb_target_t target, usb_transfer_type_t transfer_type,
     
    292272        return enqueue_transfer_in(dev, target, USB_TRANSFER_INTERRUPT,
    293273            data, size,
    294             callback, arg);
    295 }
    296 
    297 static int control_write_setup(device_t *dev, usb_target_t target,
    298     size_t max_packet_size,
    299     void *data, size_t size,
    300     usbhc_iface_transfer_out_callback_t callback, void *arg)
    301 {
    302         return enqueue_transfer_setup(dev, target, USB_TRANSFER_CONTROL,
    303             data, size,
    304             callback, arg);
    305 }
    306 
    307 static int control_write_data(device_t *dev, usb_target_t target,
    308     size_t max_packet_size,
    309     void *data, size_t size,
    310     usbhc_iface_transfer_out_callback_t callback, void *arg)
    311 {
    312         return enqueue_transfer_out(dev, target, USB_TRANSFER_CONTROL,
    313             data, size,
    314             callback, arg);
    315 }
    316 
    317 static int control_write_status(device_t *dev, usb_target_t target,
    318     usbhc_iface_transfer_in_callback_t callback, void *arg)
    319 {
    320         return enqueue_transfer_in(dev, target, USB_TRANSFER_CONTROL,
    321             NULL, 0,
    322274            callback, arg);
    323275}
     
    341293}
    342294
    343 static int control_read_setup(device_t *dev, usb_target_t target,
    344     size_t max_packet_size,
    345     void *data, size_t size,
    346     usbhc_iface_transfer_out_callback_t callback, void *arg)
    347 {
    348         return enqueue_transfer_setup(dev, target, USB_TRANSFER_CONTROL,
    349             data, size,
    350             callback, arg);
    351 }
    352 
    353 static int control_read_data(device_t *dev, usb_target_t target,
    354     size_t max_packet_size,
    355     void *data, size_t size,
    356     usbhc_iface_transfer_in_callback_t callback, void *arg)
    357 {
    358         return enqueue_transfer_in(dev, target, USB_TRANSFER_CONTROL,
    359             data, size,
    360             callback, arg);
    361 }
    362 
    363 static int control_read_status(device_t *dev, usb_target_t target,
    364     usbhc_iface_transfer_out_callback_t callback, void *arg)
    365 {
    366         return enqueue_transfer_out(dev, target, USB_TRANSFER_CONTROL,
    367             NULL, 0,
    368             callback, arg);
    369 }
    370 
    371295static int control_read(device_t *dev, usb_target_t target,
    372296    size_t max_packet_size,
     
    455379        .interrupt_in = interrupt_in,
    456380
    457         .control_write_setup = control_write_setup,
    458         .control_write_data = control_write_data,
    459         .control_write_status = control_write_status,
    460 
    461381        .control_write = control_write,
    462 
    463         .control_read_setup = control_read_setup,
    464         .control_read_data = control_read_data,
    465         .control_read_status = control_read_status,
    466 
    467382        .control_read = control_read
    468383};
  • uspace/lib/drv/generic/remote_usbhc.c

    rb6c7da6 r374552ef  
    4646static void remote_usbhc_interrupt_out(device_t *, void *, ipc_callid_t, ipc_call_t *);
    4747static void remote_usbhc_interrupt_in(device_t *, void *, ipc_callid_t, ipc_call_t *);
    48 static void remote_usbhc_control_write_setup(device_t *, void *, ipc_callid_t, ipc_call_t *);
    49 static void remote_usbhc_control_write_data(device_t *, void *, ipc_callid_t, ipc_call_t *);
    50 static void remote_usbhc_control_write_status(device_t *, void *, ipc_callid_t, ipc_call_t *);
    51 static void remote_usbhc_control_read_setup(device_t *, void *, ipc_callid_t, ipc_call_t *);
    52 static void remote_usbhc_control_read_data(device_t *, void *, ipc_callid_t, ipc_call_t *);
    53 static void remote_usbhc_control_read_status(device_t *, void *, ipc_callid_t, ipc_call_t *);
    5448static void remote_usbhc_control_write(device_t *, void *, ipc_callid_t, ipc_call_t *);
    5549static void remote_usbhc_control_read(device_t *, void *, ipc_callid_t, ipc_call_t *);
     
    7569        remote_usbhc_interrupt_in,
    7670
    77         remote_usbhc_control_write_setup,
    78         remote_usbhc_control_write_data,
    79         remote_usbhc_control_write_status,
    80 
    81         remote_usbhc_control_read_setup,
    82         remote_usbhc_control_read_data,
    83         remote_usbhc_control_read_status,
    84 
    8571        remote_usbhc_control_write,
    8672        remote_usbhc_control_read
     
    297283        }
    298284
    299         size_t expected_len = DEV_IPC_GET_ARG3(*call);
     285        size_t max_packet_size = DEV_IPC_GET_ARG3(*call);
    300286        usb_target_t target = {
    301287                .address = DEV_IPC_GET_ARG1(*call),
     
    305291        size_t len = 0;
    306292        void *buffer = NULL;
    307         if (expected_len > 0) {
    308                 int rc = async_data_write_accept(&buffer, false,
    309                     1, USB_MAX_PAYLOAD_SIZE,
    310                     0, &len);
    311 
    312                 if (rc != EOK) {
    313                         async_answer_0(callid, rc);
    314                         return;
    315                 }
     293
     294        int rc = async_data_write_accept(&buffer, false,
     295            1, USB_MAX_PAYLOAD_SIZE,
     296            0, &len);
     297
     298        if (rc != EOK) {
     299                async_answer_0(callid, rc);
     300                return;
    316301        }
    317302
     
    328313        trans->size = len;
    329314
    330         int rc = transfer_func(device, target, HACK_MAX_PACKET_SIZE,
     315        rc = transfer_func(device, target, max_packet_size,
    331316            buffer, len,
    332317            callback_out, trans);
     
    354339        }
    355340
    356         size_t len = DEV_IPC_GET_ARG3(*call);
     341        size_t max_packet_size = DEV_IPC_GET_ARG3(*call);
    357342        usb_target_t target = {
    358343                .address = DEV_IPC_GET_ARG1(*call),
     
    360345        };
    361346
     347        size_t len;
    362348        ipc_callid_t data_callid;
    363349        if (!async_data_read_receive(&data_callid, &len)) {
     
    375361        trans->size = len;
    376362
    377         int rc = transfer_func(device, target, HACK_MAX_PACKET_SIZE_INTERRUPT_IN,
     363        int rc = transfer_func(device, target, max_packet_size,
    378364            trans->buffer, len,
    379365            callback_in, trans);
     
    385371}
    386372
    387 /** Process status part of control transfer.
    388  *
    389  * @param device Target device.
    390  * @param callid Initiating caller.
    391  * @param call Initiating call.
    392  * @param direction Transfer direction (read ~ in, write ~ out).
    393  * @param transfer_in_func Transfer function for control read (might be NULL).
    394  * @param transfer_out_func Transfer function for control write (might be NULL).
    395  */
    396 static void remote_usbhc_status_transfer(device_t *device,
    397     ipc_callid_t callid, ipc_call_t *call,
    398     usb_direction_t direction,
    399     int (*transfer_in_func)(device_t *, usb_target_t,
    400         usbhc_iface_transfer_in_callback_t, void *),
    401     int (*transfer_out_func)(device_t *, usb_target_t,
    402         usbhc_iface_transfer_out_callback_t, void *))
    403 {
    404         switch (direction) {
    405                 case USB_DIRECTION_IN:
    406                         if (!transfer_in_func) {
    407                                 async_answer_0(callid, ENOTSUP);
    408                                 return;
    409                         }
    410                         break;
    411                 case USB_DIRECTION_OUT:
    412                         if (!transfer_out_func) {
    413                                 async_answer_0(callid, ENOTSUP);
    414                                 return;
    415                         }
    416                         break;
    417                 default:
    418                         assert(false && "unreachable code");
    419                         break;
    420         }
    421 
    422         usb_target_t target = {
    423                 .address = DEV_IPC_GET_ARG1(*call),
    424                 .endpoint = DEV_IPC_GET_ARG2(*call)
    425         };
    426 
    427         async_transaction_t *trans = async_transaction_create(callid);
    428         if (trans == NULL) {
    429                 async_answer_0(callid, ENOMEM);
    430                 return;
    431         }
    432 
    433         int rc;
    434         switch (direction) {
    435                 case USB_DIRECTION_IN:
    436                         rc = transfer_in_func(device, target,
    437                             callback_in, trans);
    438                         break;
    439                 case USB_DIRECTION_OUT:
    440                         rc = transfer_out_func(device, target,
    441                             callback_out, trans);
    442                         break;
    443                 default:
    444                         assert(false && "unreachable code");
    445                         break;
    446         }
    447 
    448         if (rc != EOK) {
    449                 async_answer_0(callid, rc);
    450                 async_transaction_destroy(trans);
    451         }
    452 }
    453 
    454 
    455373void remote_usbhc_interrupt_out(device_t *device, void *iface,
    456374    ipc_callid_t callid, ipc_call_t *call)
     
    471389        return remote_usbhc_in_transfer(device, callid, call,
    472390            usb_iface->interrupt_in);
    473 }
    474 
    475 void remote_usbhc_control_write_setup(device_t *device, void *iface,
    476     ipc_callid_t callid, ipc_call_t *call)
    477 {
    478         usbhc_iface_t *usb_iface = (usbhc_iface_t *) iface;
    479         assert(usb_iface != NULL);
    480 
    481         return remote_usbhc_out_transfer(device, callid, call,
    482             usb_iface->control_write_setup);
    483 }
    484 
    485 void remote_usbhc_control_write_data(device_t *device, void *iface,
    486     ipc_callid_t callid, ipc_call_t *call)
    487 {
    488         usbhc_iface_t *usb_iface = (usbhc_iface_t *) iface;
    489         assert(usb_iface != NULL);
    490 
    491         return remote_usbhc_out_transfer(device, callid, call,
    492             usb_iface->control_write_data);
    493 }
    494 
    495 void remote_usbhc_control_write_status(device_t *device, void *iface,
    496     ipc_callid_t callid, ipc_call_t *call)
    497 {
    498         usbhc_iface_t *usb_iface = (usbhc_iface_t *) iface;
    499         assert(usb_iface != NULL);
    500 
    501         return remote_usbhc_status_transfer(device, callid, call,
    502             USB_DIRECTION_IN, usb_iface->control_write_status, NULL);
    503 }
    504 
    505 void remote_usbhc_control_read_setup(device_t *device, void *iface,
    506     ipc_callid_t callid, ipc_call_t *call)
    507 {
    508         usbhc_iface_t *usb_iface = (usbhc_iface_t *) iface;
    509         assert(usb_iface != NULL);
    510 
    511         return remote_usbhc_out_transfer(device, callid, call,
    512             usb_iface->control_read_setup);
    513 }
    514 
    515 void remote_usbhc_control_read_data(device_t *device, void *iface,
    516             ipc_callid_t callid, ipc_call_t *call)
    517 {
    518         usbhc_iface_t *usb_iface = (usbhc_iface_t *) iface;
    519         assert(usb_iface != NULL);
    520 
    521         return remote_usbhc_in_transfer(device, callid, call,
    522             usb_iface->control_read_data);
    523 }
    524 
    525 void remote_usbhc_control_read_status(device_t *device, void *iface,
    526             ipc_callid_t callid, ipc_call_t *call)
    527 {
    528         usbhc_iface_t *usb_iface = (usbhc_iface_t *) iface;
    529         assert(usb_iface != NULL);
    530 
    531         return remote_usbhc_status_transfer(device, callid, call,
    532             USB_DIRECTION_OUT, NULL, usb_iface->control_read_status);
    533391}
    534392
     
    549407        };
    550408        size_t data_buffer_len = DEV_IPC_GET_ARG3(*call);
     409        size_t max_packet_size = DEV_IPC_GET_ARG4(*call);
    551410
    552411        int rc;
     
    584443        trans->size = data_buffer_len;
    585444
    586         rc = usb_iface->control_write(device, target, HACK_MAX_PACKET_SIZE,
     445        rc = usb_iface->control_write(device, target, max_packet_size,
    587446            setup_packet, setup_packet_len,
    588447            data_buffer, data_buffer_len,
     
    611470                .endpoint = DEV_IPC_GET_ARG2(*call)
    612471        };
     472        size_t max_packet_size = DEV_IPC_GET_ARG3(*call);
    613473
    614474        int rc;
     
    648508        }
    649509
    650         rc = usb_iface->control_read(device, target, HACK_MAX_PACKET_SIZE,
     510        rc = usb_iface->control_read(device, target, max_packet_size,
    651511            setup_packet, setup_packet_len,
    652512            trans->buffer, trans->size,
  • uspace/lib/drv/include/usbhc_iface.h

    rb6c7da6 r374552ef  
    5353 *   - argument #1 is target address
    5454 *   - argument #2 is target endpoint
    55  *   - argument #3 is buffer size
     55 *   - argument #3 is max packet size of the endpoint
    5656 * - this call is immediately followed by IPC data write (from caller)
    5757 * - the initial call (and the whole transaction) is answer after the
     
    6666 *   - argument #1 is target address
    6767 *   - argument #2 is target endpoint
    68  *   - argument #3 is buffer size
     68 *   - argument #3 is max packet size of the endpoint
    6969 * - this call is immediately followed by IPC data read (async version)
    7070 * - the call is not answered until the device returns some data (or until
     
    153153        IPC_M_USBHC_INTERRUPT_IN,
    154154
    155 
    156         /** Start WRITE control transfer.
    157          * See explanation at usb_iface_funcs_t (OUT transaction).
    158          */
    159         IPC_M_USBHC_CONTROL_WRITE_SETUP,
    160 
    161         /** Send control-transfer data to device.
    162          * See explanation at usb_iface_funcs_t (OUT transaction).
    163          */
    164         IPC_M_USBHC_CONTROL_WRITE_DATA,
    165 
    166         /** Terminate WRITE control transfer.
    167          * See explanation at usb_iface_funcs_t (NO-DATA transaction).
    168          */
    169         IPC_M_USBHC_CONTROL_WRITE_STATUS,
    170 
    171 
    172 
    173         /** Start READ control transfer.
    174          * See explanation at usb_iface_funcs_t (OUT transaction).
    175          */
    176         IPC_M_USBHC_CONTROL_READ_SETUP,
    177 
    178         /** Get control-transfer data from device.
    179          * See explanation at usb_iface_funcs_t (IN transaction).
    180          */
    181         IPC_M_USBHC_CONTROL_READ_DATA,
    182 
    183         /** Terminate READ control transfer.
    184          * See explanation at usb_iface_funcs_t (NO-DATA transaction).
    185          */
    186         IPC_M_USBHC_CONTROL_READ_STATUS,
    187 
    188155        /** Issue control WRITE transfer.
    189156         * See explanation at usb_iface_funcs_t (OUT transaction) for
     
    194161        IPC_M_USBHC_CONTROL_WRITE,
    195162
    196         /** Issue control WRITE transfer.
     163        /** Issue control READ transfer.
    197164         * See explanation at usb_iface_funcs_t (IN transaction) for
    198165         * call parameters.
    199          * This call is immediately followed by IPC data read from the caller
    200          * (setup packet).
    201          * Actual data are retrieved through IPC_M_USBHC_GET_BUFFER.
     166         * This call is immediately followed by IPC data write from the caller
     167         * (setup packet) and IPC data read (buffer that was read).
    202168         */
    203169        IPC_M_USBHC_CONTROL_READ,
     
    241207        usbhc_iface_transfer_in_t interrupt_in;
    242208
    243         usbhc_iface_transfer_setup_t control_write_setup;
    244         usbhc_iface_transfer_out_t control_write_data;
    245         int (*control_write_status)(device_t *, usb_target_t,
    246             usbhc_iface_transfer_in_callback_t, void *);
    247 
    248         usbhc_iface_transfer_setup_t control_read_setup;
    249         usbhc_iface_transfer_in_t control_read_data;
    250         int (*control_read_status)(device_t *, usb_target_t,
    251             usbhc_iface_transfer_out_callback_t, void *);
    252 
    253209        int (*control_write)(device_t *, usb_target_t,
    254210            size_t,
  • uspace/lib/usb/src/pipes.c

    rb6c7da6 r374552ef  
    3535#include <usb/usb.h>
    3636#include <usb/pipes.h>
     37#include <usbhc_iface.h>
    3738#include <errno.h>
    3839#include <assert.h>
    39 #include <usb/usbdrv.h>
     40
     41/** Tell USB address assigned to given device.
     42 *
     43 * @param phone Phone to my HC.
     44 * @param dev Device in question.
     45 * @return USB address or error code.
     46 */
     47static usb_address_t get_my_address(int phone, device_t *dev)
     48{
     49        sysarg_t address;
     50        int rc = async_req_2_1(phone, DEV_IFACE_ID(USBHC_DEV_IFACE),
     51            IPC_M_USBHC_GET_ADDRESS,
     52            dev->handle, &address);
     53
     54        if (rc != EOK) {
     55                return rc;
     56        }
     57
     58        return (usb_address_t) address;
     59}
    4060
    4161/** Initialize connection to USB device.
     
    5575        usb_address_t my_address;
    5676
    57         rc = usb_drv_find_hc(device, &hc_handle);
     77        rc = usb_hc_find(device->handle, &hc_handle);
    5878        if (rc != EOK) {
    5979                return rc;
     
    6585        }
    6686
    67         my_address = usb_drv_get_my_address(hc_phone, device);
     87        my_address = get_my_address(hc_phone, device);
    6888        if (my_address < 0) {
    6989                rc = my_address;
  • uspace/lib/usb/src/pipesio.c

    rb6c7da6 r374552ef  
    7878         * Make call identifying target USB device and type of transfer.
    7979         */
    80         aid_t opening_request = async_send_3(pipe->hc_phone,
     80        aid_t opening_request = async_send_4(pipe->hc_phone,
    8181            DEV_IFACE_ID(USBHC_DEV_IFACE), ipc_method,
    8282            pipe->wire->address, pipe->endpoint_no,
     83            pipe->max_packet_size,
    8384            NULL);
    8485        if (opening_request == 0) {
     
    201202         * Make call identifying target USB device and type of transfer.
    202203         */
    203         aid_t opening_request = async_send_3(pipe->hc_phone,
     204        aid_t opening_request = async_send_4(pipe->hc_phone,
    204205            DEV_IFACE_ID(USBHC_DEV_IFACE), ipc_method,
    205206            pipe->wire->address, pipe->endpoint_no,
     207            pipe->max_packet_size,
    206208            NULL);
    207209        if (opening_request == 0) {
     
    283285         * Make call identifying target USB device and control transfer type.
    284286         */
    285         aid_t opening_request = async_send_3(pipe->hc_phone,
     287        aid_t opening_request = async_send_4(pipe->hc_phone,
    286288            DEV_IFACE_ID(USBHC_DEV_IFACE), IPC_M_USBHC_CONTROL_READ,
    287289            pipe->wire->address, pipe->endpoint_no,
     290            pipe->max_packet_size,
    288291            NULL);
    289292        if (opening_request == 0) {
     
    402405         * Make call identifying target USB device and control transfer type.
    403406         */
    404         aid_t opening_request = async_send_4(pipe->hc_phone,
     407        aid_t opening_request = async_send_5(pipe->hc_phone,
    405408            DEV_IFACE_ID(USBHC_DEV_IFACE), IPC_M_USBHC_CONTROL_WRITE,
    406409            pipe->wire->address, pipe->endpoint_no,
    407410            data_buffer_size,
     411            pipe->max_packet_size,
    408412            NULL);
    409413        if (opening_request == 0) {
  • uspace/lib/usb/src/usbdrv.c

    rb6c7da6 r374552ef  
    3434 */
    3535#include <usb/usbdrv.h>
    36 #include <usbhc_iface.h>
    37 #include <usb_iface.h>
    3836#include <errno.h>
    39 #include <str_error.h>
    40 
    41 /** Information about pending transaction on HC. */
    42 typedef struct {
    43         /** Phone to host controller driver. */
    44         int phone;
    45         /** Data buffer. */
    46         void *buffer;
    47         /** Buffer size. */
    48         size_t size;
    49         /** Storage for actual number of bytes transferred. */
    50         size_t *size_transferred;
    51         /** Initial call reply data. */
    52         ipc_call_t reply;
    53         /** Initial call identifier. */
    54         aid_t request;
    55         /** Reply data for data read call. */
    56         ipc_call_t read_reply;
    57         /** Data read call identifier. */
    58         aid_t read_request;
    59 } transfer_info_t;
     37
    6038
    6139/** Find handle of host controller the device is physically attached to.
     
    6745int usb_drv_find_hc(device_t *dev, devman_handle_t *handle)
    6846{
    69         if (dev == NULL) {
    70                 return EBADMEM;
    71         }
    72         if (handle == NULL) {
    73                 return EBADMEM;
    74         }
    75 
    76         int parent_phone = devman_parent_device_connect(dev->handle,
    77             IPC_FLAG_BLOCKING);
    78         if (parent_phone < 0) {
    79                 return parent_phone;
    80         }
    81 
    82         devman_handle_t h;
    83         int rc = async_req_1_1(parent_phone, DEV_IFACE_ID(USB_DEV_IFACE),
    84             IPC_M_USB_GET_HOST_CONTROLLER_HANDLE, &h);
    85 
    86         async_hangup(parent_phone);
    87 
    88         if (rc != EOK) {
    89                 return rc;
    90         }
    91 
    92         *handle = h;
    93 
    94         return EOK;
     47        return ENOTSUP;
    9548}
    9649
     
    10558    unsigned int flags)
    10659{
    107         return devman_device_connect(hc_handle, flags);
     60        return ENOTSUP;
    10861}
    10962
     
    11669int usb_drv_hc_connect_auto(device_t *dev, unsigned int flags)
    11770{
    118         int rc;
    119         devman_handle_t hc_handle;
    120 
    121         /*
    122          * Call parent hub to obtain device handle of respective HC.
    123          */
    124         rc = usb_drv_find_hc(dev, &hc_handle);
    125         if (rc != EOK) {
    126                 return rc;
    127         }
    128        
    129         return usb_drv_hc_connect(dev, hc_handle, flags);
     71        return ENOTSUP;
    13072}
    13173
     
    13880usb_address_t usb_drv_get_my_address(int phone, device_t *dev)
    13981{
    140         sysarg_t address;
    141         int rc = async_req_2_1(phone, DEV_IFACE_ID(USBHC_DEV_IFACE),
    142             IPC_M_USBHC_GET_ADDRESS,
    143             dev->handle, &address);
    144 
    145         if (rc != EOK) {
    146                 return rc;
    147         }
    148 
    149         return (usb_address_t) address;
     82        return ENOTSUP;
    15083}
    15184
     
    15790int usb_drv_reserve_default_address(int phone)
    15891{
    159         return async_req_1_0(phone, DEV_IFACE_ID(USBHC_DEV_IFACE),
    160             IPC_M_USBHC_RESERVE_DEFAULT_ADDRESS);
     92        return ENOTSUP;
    16193}
    16294
     
    168100int usb_drv_release_default_address(int phone)
    169101{
    170         return async_req_1_0(phone, DEV_IFACE_ID(USBHC_DEV_IFACE),
    171             IPC_M_USBHC_RELEASE_DEFAULT_ADDRESS);
     102        return ENOTSUP;
    172103}
    173104
     
    179110usb_address_t usb_drv_request_address(int phone)
    180111{
    181         sysarg_t address;
    182         int rc = async_req_1_1(phone, DEV_IFACE_ID(USBHC_DEV_IFACE),
    183             IPC_M_USBHC_REQUEST_ADDRESS, &address);
    184         if (rc != EOK) {
    185                 return rc;
    186         } else {
    187                 return (usb_address_t) address;
    188         }
     112        return ENOTSUP;
    189113}
    190114
     
    199123    devman_handle_t handle)
    200124{
    201         int rc = async_req_3_0(phone, DEV_IFACE_ID(USBHC_DEV_IFACE),
    202             IPC_M_USBHC_BIND_ADDRESS,
    203             address, handle);
    204 
    205         return rc;
     125        return ENOTSUP;
    206126}
    207127
     
    214134int usb_drv_release_address(int phone, usb_address_t address)
    215135{
    216         return async_req_2_0(phone, DEV_IFACE_ID(USBHC_DEV_IFACE),
    217             IPC_M_USBHC_RELEASE_ADDRESS, address);
    218 }
    219 
    220 /** Send data to HCD.
    221  *
    222  * @param phone Phone to HC.
    223  * @param method Method used for calling.
    224  * @param target Targeted device.
    225  * @param buffer Data buffer (NULL to skip data transfer phase).
    226  * @param size Buffer size (must be zero when @p buffer is NULL).
    227  * @param handle Storage for transaction handle (cannot be NULL).
    228  * @return Error status.
    229  * @retval EINVAL Invalid parameter.
    230  * @retval ENOMEM Not enough memory to complete the operation.
    231  */
    232 static int async_send_buffer(int phone, int method,
    233     usb_target_t target,
    234     void *buffer, size_t size,
    235     usb_handle_t *handle)
    236 {
    237         if (phone < 0) {
    238                 return EINVAL;
    239         }
    240 
    241         if ((buffer == NULL) && (size > 0)) {
    242                 return EINVAL;
    243         }
    244 
    245         if (handle == NULL) {
    246                 return EINVAL;
    247         }
    248 
    249         transfer_info_t *transfer
    250             = (transfer_info_t *) malloc(sizeof(transfer_info_t));
    251         if (transfer == NULL) {
    252                 return ENOMEM;
    253         }
    254 
    255         transfer->read_request = 0;
    256         transfer->size_transferred = NULL;
    257         transfer->buffer = NULL;
    258         transfer->size = 0;
    259         transfer->phone = phone;
    260 
    261         int rc;
    262 
    263         transfer->request = async_send_4(phone,
    264             DEV_IFACE_ID(USBHC_DEV_IFACE),
    265             method,
    266             target.address, target.endpoint,
    267             size,
    268             &transfer->reply);
    269 
    270         if (size > 0) {
    271                 rc = async_data_write_start(phone, buffer, size);
    272                 if (rc != EOK) {
    273                         async_wait_for(transfer->request, NULL);
    274                         return rc;
    275                 }
    276         }
    277 
    278         *handle = (usb_handle_t) transfer;
    279 
    280         return EOK;
    281 }
    282 
    283 /** Prepare data retrieval.
    284  *
    285  * @param phone Opened phone to HCD.
    286  * @param method Method used for calling.
    287  * @param target Targeted device.
    288  * @param buffer Buffer where to store retrieved data
    289  *      (NULL to skip data transfer phase).
    290  * @param size Buffer size (must be zero when @p buffer is NULL).
    291  * @param actual_size Storage where actual number of bytes transferred will
    292  *      be stored.
    293  * @param handle Storage for transaction handle (cannot be NULL).
    294  * @return Error status.
    295  * @retval EINVAL Invalid parameter.
    296  * @retval ENOMEM Not enough memory to complete the operation.
    297  */
    298 static int async_recv_buffer(int phone, int method,
    299     usb_target_t target,
    300     void *buffer, size_t size, size_t *actual_size,
    301     usb_handle_t *handle)
    302 {
    303         if (phone < 0) {
    304                 return EINVAL;
    305         }
    306 
    307         if ((buffer == NULL) && (size > 0)) {
    308                 return EINVAL;
    309         }
    310 
    311         if (handle == NULL) {
    312                 return EINVAL;
    313         }
    314 
    315         transfer_info_t *transfer
    316             = (transfer_info_t *) malloc(sizeof(transfer_info_t));
    317         if (transfer == NULL) {
    318                 return ENOMEM;
    319         }
    320 
    321         transfer->read_request = 0;
    322         transfer->size_transferred = actual_size;
    323         transfer->buffer = buffer;
    324         transfer->size = size;
    325         transfer->phone = phone;
    326 
    327         transfer->request = async_send_4(phone,
    328             DEV_IFACE_ID(USBHC_DEV_IFACE),
    329             method,
    330             target.address, target.endpoint,
    331             size,
    332             &transfer->reply);
    333 
    334         if (buffer != NULL) {
    335                 transfer->read_request = async_data_read(phone, buffer, size,
    336                     &transfer->read_reply);
    337         }
    338 
    339         *handle = (usb_handle_t) transfer;
    340 
    341         return EOK;
    342 }
    343 
     136        return ENOTSUP;
     137}
    344138
    345139/** Blocks caller until given USB transaction is finished.
     
    355149int usb_drv_async_wait_for(usb_handle_t handle)
    356150{
    357         if (handle == 0) {
    358                 return EBADMEM;
    359         }
    360 
    361         int rc = EOK;
    362 
    363         transfer_info_t *transfer = (transfer_info_t *) handle;
    364 
    365         sysarg_t answer_rc;
    366 
    367         /*
    368          * If the buffer is not NULL, we must accept some data.
    369          */
    370         if ((transfer->buffer != NULL) && (transfer->size > 0)) {
    371                 async_wait_for(transfer->read_request, &answer_rc);
    372 
    373                 if (answer_rc != EOK) {
    374                         rc = (int) answer_rc;
    375                         goto leave;
    376                 }
    377 
    378                 if (transfer->size_transferred != NULL) {
    379                         *(transfer->size_transferred)
    380                             = IPC_GET_ARG2(transfer->read_reply);
    381                 }
    382         }
    383 
    384         async_wait_for(transfer->request, &answer_rc);
    385 
    386         if (answer_rc != EOK) {
    387                 rc = (int) answer_rc;
    388                 goto leave;
    389         }
    390 
    391 leave:
    392         free(transfer);
    393 
    394         return rc;
     151        return ENOTSUP;
    395152}
    396153
     
    400157    usb_handle_t *handle)
    401158{
    402         return async_send_buffer(phone,
    403             IPC_M_USBHC_INTERRUPT_OUT,
    404             target,
    405             buffer, size,
    406             handle);
     159        return ENOTSUP;
    407160}
    408161
     
    412165    usb_handle_t *handle)
    413166{
    414         return async_recv_buffer(phone,
    415             IPC_M_USBHC_INTERRUPT_IN,
    416             target,
    417             buffer, size, actual_size,
    418             handle);
     167        return ENOTSUP;
    419168}
    420169
     
    424173    usb_handle_t *handle)
    425174{
    426         return async_send_buffer(phone,
    427             IPC_M_USBHC_CONTROL_WRITE_SETUP,
    428             target,
    429             buffer, size,
    430             handle);
     175        return ENOTSUP;
    431176}
    432177
     
    436181    usb_handle_t *handle)
    437182{
    438         return async_send_buffer(phone,
    439             IPC_M_USBHC_CONTROL_WRITE_DATA,
    440             target,
    441             buffer, size,
    442             handle);
     183        return ENOTSUP;
    443184}
    444185
     
    447188    usb_handle_t *handle)
    448189{
    449         return async_recv_buffer(phone,
    450             IPC_M_USBHC_CONTROL_WRITE_STATUS,
    451             target,
    452             NULL, 0, NULL,
    453             handle);
     190        return ENOTSUP;
    454191}
    455192
     
    460197    usb_handle_t *handle)
    461198{
    462         // FIXME - check input parameters instead of asserting them
    463         assert(phone > 0);
    464         assert(setup_packet != NULL);
    465         assert(setup_packet_size > 0);
    466         assert(((buffer != NULL) && (buffer_size > 0))
    467             || ((buffer == NULL) && (buffer_size == 0)));
    468         assert(handle != NULL);
    469 
    470         transfer_info_t *transfer
    471             = (transfer_info_t *) malloc(sizeof(transfer_info_t));
    472         if (transfer == NULL) {
    473                 return ENOMEM;
    474         }
    475 
    476         transfer->read_request = 0;
    477         transfer->size_transferred = NULL;
    478         transfer->buffer = NULL;
    479         transfer->size = 0;
    480         transfer->phone = phone;
    481 
    482         int rc;
    483 
    484         transfer->request = async_send_3(phone,
    485             DEV_IFACE_ID(USBHC_DEV_IFACE),
    486             IPC_M_USBHC_CONTROL_WRITE,
    487             target.address, target.endpoint,
    488             &transfer->reply);
    489 
    490         rc = async_data_write_start(phone, setup_packet, setup_packet_size);
    491         if (rc != EOK) {
    492                 async_wait_for(transfer->request, NULL);
    493                 return rc;
    494         }
    495 
    496         if (buffer_size > 0) {
    497                 rc = async_data_write_start(phone, buffer, buffer_size);
    498                 if (rc != EOK) {
    499                         async_wait_for(transfer->request, NULL);
    500                         return rc;
    501                 }
    502         }
    503 
    504         *handle = (usb_handle_t) transfer;
    505 
    506         return EOK;
     199        return ENOTSUP;
    507200}
    508201
     
    512205    usb_handle_t *handle)
    513206{
    514         return async_send_buffer(phone,
    515             IPC_M_USBHC_CONTROL_READ_SETUP,
    516             target,
    517             buffer, size,
    518             handle);
     207        return ENOTSUP;
    519208}
    520209
     
    524213    usb_handle_t *handle)
    525214{
    526         return async_recv_buffer(phone,
    527             IPC_M_USBHC_CONTROL_READ_DATA,
    528             target,
    529             buffer, size, actual_size,
    530             handle);
     215        return ENOTSUP;
    531216}
    532217
     
    535220    usb_handle_t *handle)
    536221{
    537         return async_send_buffer(phone,
    538             IPC_M_USBHC_CONTROL_READ_STATUS,
    539             target,
    540             NULL, 0,
    541             handle);
     222        return ENOTSUP;
    542223}
    543224
     
    548229    usb_handle_t *handle)
    549230{
    550         // FIXME - check input parameters instead of asserting them
    551         assert(phone > 0);
    552         assert(setup_packet != NULL);
    553         assert(setup_packet_size > 0);
    554         assert(buffer != NULL);
    555         assert(buffer_size > 0);
    556         assert(handle != NULL);
    557 
    558         transfer_info_t *transfer
    559             = (transfer_info_t *) malloc(sizeof(transfer_info_t));
    560         if (transfer == NULL) {
    561                 return ENOMEM;
    562         }
    563 
    564         transfer->size_transferred = actual_size;
    565         transfer->buffer = buffer;
    566         transfer->size = buffer_size;
    567         transfer->phone = phone;
    568 
    569         int rc;
    570 
    571         transfer->request = async_send_4(phone,
    572             DEV_IFACE_ID(USBHC_DEV_IFACE),
    573             IPC_M_USBHC_CONTROL_READ,
    574             target.address, target.endpoint,
    575             buffer_size,
    576             &transfer->reply);
    577 
    578         rc = async_data_write_start(phone, setup_packet, setup_packet_size);
    579         if (rc != EOK) {
    580                 async_wait_for(transfer->request, NULL);
    581                 return rc;
    582         }
    583 
    584         transfer->read_request = async_data_read(phone, buffer, buffer_size,
    585             &transfer->read_reply);
    586 
    587         *handle = (usb_handle_t) transfer;
    588 
    589         return EOK;
     231        return ENOTSUP;
    590232}
    591233
Note: See TracChangeset for help on using the changeset viewer.