Changeset 1968de5 in mainline for uspace/lib/drv


Ignore:
Timestamp:
2011-02-11T16:27:45Z (14 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
608afb9
Parents:
03197ffc (diff), 5842493 (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 get_buffer request removal (ticket 54)

Location:
uspace/lib/drv
Files:
2 edited

Legend:

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

    r03197ffc r1968de5  
    4242
    4343static void remote_usbhc_get_address(device_t *, void *, ipc_callid_t, ipc_call_t *);
    44 static void remote_usbhc_get_buffer(device_t *, void *, ipc_callid_t, ipc_call_t *);
    4544static void remote_usbhc_interrupt_out(device_t *, void *, ipc_callid_t, ipc_call_t *);
    4645static void remote_usbhc_interrupt_in(device_t *, void *, ipc_callid_t, ipc_call_t *);
     
    6463        remote_usbhc_get_address,
    6564
    66         remote_usbhc_get_buffer,
    67 
    6865        remote_usbhc_reserve_default_address,
    6966        remote_usbhc_release_default_address,
     
    9895typedef struct {
    9996        ipc_callid_t caller;
     97        ipc_callid_t data_caller;
    10098        void *buffer;
    10199        void *setup_packet;
     
    127125
    128126        trans->caller = caller;
     127        trans->data_caller = 0;
    129128        trans->buffer = NULL;
    130129        trans->setup_packet = NULL;
     
    155154}
    156155
    157 void remote_usbhc_get_buffer(device_t *device, void *iface,
    158     ipc_callid_t callid, ipc_call_t *call)
    159 {
    160         sysarg_t buffer_hash = DEV_IPC_GET_ARG1(*call);
    161         async_transaction_t * trans = (async_transaction_t *)buffer_hash;
    162         if (trans == NULL) {
    163                 async_answer_0(callid, ENOENT);
    164                 return;
    165         }
    166         if (trans->buffer == NULL) {
    167                 async_answer_0(callid, EINVAL);
    168                 async_transaction_destroy(trans);
    169                 return;
    170         }
    171 
    172         ipc_callid_t cid;
    173         size_t accepted_size;
    174         if (!async_data_read_receive(&cid, &accepted_size)) {
    175                 async_answer_0(callid, EINVAL);
    176                 async_transaction_destroy(trans);
    177                 return;
    178         }
    179 
    180         if (accepted_size > trans->size) {
    181                 accepted_size = trans->size;
    182         }
    183         async_data_read_finalize(cid, trans->buffer, accepted_size);
    184 
    185         async_answer_1(callid, EOK, accepted_size);
    186 
    187         async_transaction_destroy(trans);
    188 }
    189 
    190156void remote_usbhc_reserve_default_address(device_t *device, void *iface,
    191157    ipc_callid_t callid, ipc_call_t *call)
     
    290256        if (outcome != USB_OUTCOME_OK) {
    291257                async_answer_0(trans->caller, outcome);
     258                if (trans->data_caller) {
     259                        async_answer_0(trans->data_caller, EINTR);
     260                }
    292261                async_transaction_destroy(trans);
    293262                return;
     
    295264
    296265        trans->size = actual_size;
    297         async_answer_1(trans->caller, USB_OUTCOME_OK, (sysarg_t)trans);
     266
     267        if (trans->data_caller) {
     268                async_data_read_finalize(trans->data_caller,
     269                    trans->buffer, actual_size);
     270        }
     271
     272        async_answer_0(trans->caller, USB_OUTCOME_OK);
     273
     274        async_transaction_destroy(trans);
    298275}
    299276
     
    376353        };
    377354
     355        ipc_callid_t data_callid;
     356        if (!async_data_read_receive(&data_callid, &len)) {
     357                async_answer_0(callid, EPARTY);
     358                return;
     359        }
     360
    378361        async_transaction_t *trans = async_transaction_create(callid);
    379362        if (trans == NULL) {
     
    381364                return;
    382365        }
     366        trans->data_caller = data_callid;
    383367        trans->buffer = malloc(len);
    384368        trans->size = len;
     
    630614        }
    631615
     616        ipc_callid_t data_callid;
     617        if (!async_data_read_receive(&data_callid, &data_len)) {
     618                async_answer_0(callid, EPARTY);
     619                free(setup_packet);
     620                return;
     621        }
     622
    632623        async_transaction_t *trans = async_transaction_create(callid);
    633624        if (trans == NULL) {
     
    636627                return;
    637628        }
     629        trans->data_caller = data_callid;
    638630        trans->setup_packet = setup_packet;
    639631        trans->size = data_len;
  • uspace/lib/drv/include/usbhc_iface.h

    r03197ffc r1968de5  
    6666 *   - argument #2 is target endpoint
    6767 *   - argument #3 is buffer size
     68 * - this call is immediately followed by IPC data read (async version)
    6869 * - the call is not answered until the device returns some data (or until
    6970 *   error occurs)
    70  * - if the call is answered with EOK, first argument of the answer is buffer
    71  *   hash that could be used to retrieve the actual data
    7271 *
    7372 * Some special methods (NO-DATA transactions) do not send any data. These
    7473 * might behave as both OUT or IN transactions because communication parts
    7574 * where actual buffers are exchanged are omitted.
    76  *
    77  * The mentioned data retrieval can be done any time after receiving EOK
    78  * answer to IN method.
    79  * This retrieval is done using the IPC_M_USBHC_GET_BUFFER where
    80  * the first argument is buffer hash from call answer.
    81  * This call must be immediately followed by data read-in and after the
    82  * data are transferred, the initial call (IPC_M_USBHC_GET_BUFFER)
    83  * is answered. Each buffer can be retrieved only once.
    84  *
     75 **
    8576 * For all these methods, wrap functions exists. Important rule: functions
    8677 * for IN transactions have (as parameters) buffers where retrieved data
     
    10495        IPC_M_USBHC_GET_ADDRESS,
    10596
    106         /** Asks for data buffer.
    107          * See explanation at usb_iface_funcs_t.
    108          * This function does not have counter part in functional interface
    109          * as it is handled by the remote part itself.
    110          */
    111         IPC_M_USBHC_GET_BUFFER,
    112 
    11397
    11498        /** Reserve usage of default address.
Note: See TracChangeset for help on using the changeset viewer.