Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 24c8bf8 in mainline


Ignore:
Timestamp:
2017-12-30T21:36:08Z (4 years ago)
Author:
Petr Manek <petr.manek@…>
Branches:
lfn, master
Children:
2523293
Parents:
bf7b747
git-author:
Petr Manek <petr.manek@…> (2017-12-30 21:33:41)
git-committer:
Petr Manek <petr.manek@…> (2017-12-30 21:36:08)
Message:

libdrv: extend usbdiag interface with data validity tests

Location:
uspace/lib/drv
Files:
2 edited

Legend:

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

    rbf7b747 r24c8bf8  
    4848        IPC_M_USBDIAG_BURST_BULK_OUT,
    4949        IPC_M_USBDIAG_BURST_ISOCH_IN,
    50         IPC_M_USBDIAG_BURST_ISOCH_OUT
     50        IPC_M_USBDIAG_BURST_ISOCH_OUT,
     51        IPC_M_USBDIAG_DATA_INTR_IN,
     52        IPC_M_USBDIAG_DATA_INTR_OUT,
     53        IPC_M_USBDIAG_DATA_BULK_IN,
     54        IPC_M_USBDIAG_DATA_BULK_OUT,
     55        IPC_M_USBDIAG_DATA_ISOCH_IN,
     56        IPC_M_USBDIAG_DATA_ISOCH_OUT
    5157} usb_iface_funcs_t;
    5258
     
    139145        sysarg_t duration_;
    140146        const int rc = async_req_3_1(exch, DEV_IFACE_ID(USBDIAG_DEV_IFACE), IPC_M_USBDIAG_BURST_ISOCH_OUT, cycles, size, &duration_);
     147
     148        if (rc == EOK && duration)
     149                *duration = duration_;
     150
     151        return rc;
     152}
     153
     154int usbdiag_data_intr_in(async_exch_t *exch, int cycles, size_t size, usbdiag_dur_t *duration)
     155{
     156        if (!exch)
     157                return EBADMEM;
     158
     159        sysarg_t duration_;
     160        const int rc = async_req_3_1(exch, DEV_IFACE_ID(USBDIAG_DEV_IFACE), IPC_M_USBDIAG_DATA_INTR_IN, cycles, size, &duration_);
     161
     162        if (rc == EOK && duration)
     163                *duration = duration_;
     164
     165        return rc;
     166}
     167
     168int usbdiag_data_intr_out(async_exch_t *exch, int cycles, size_t size, usbdiag_dur_t *duration)
     169{
     170        if (!exch)
     171                return EBADMEM;
     172
     173        sysarg_t duration_;
     174        const int rc = async_req_3_1(exch, DEV_IFACE_ID(USBDIAG_DEV_IFACE), IPC_M_USBDIAG_DATA_INTR_OUT, cycles, size, &duration_);
     175
     176        if (rc == EOK && duration)
     177                *duration = duration_;
     178
     179        return rc;
     180}
     181
     182int usbdiag_data_bulk_in(async_exch_t *exch, int cycles, size_t size, usbdiag_dur_t *duration)
     183{
     184        if (!exch)
     185                return EBADMEM;
     186
     187        sysarg_t duration_;
     188        const int rc = async_req_3_1(exch, DEV_IFACE_ID(USBDIAG_DEV_IFACE), IPC_M_USBDIAG_DATA_BULK_IN, cycles, size, &duration_);
     189
     190        if (rc == EOK && duration)
     191                *duration = duration_;
     192
     193        return rc;
     194}
     195
     196int usbdiag_data_bulk_out(async_exch_t *exch, int cycles, size_t size, usbdiag_dur_t *duration)
     197{
     198        if (!exch)
     199                return EBADMEM;
     200
     201        sysarg_t duration_;
     202        const int rc = async_req_3_1(exch, DEV_IFACE_ID(USBDIAG_DEV_IFACE), IPC_M_USBDIAG_DATA_BULK_OUT, cycles, size, &duration_);
     203
     204        if (rc == EOK && duration)
     205                *duration = duration_;
     206
     207        return rc;
     208}
     209
     210int usbdiag_data_isoch_in(async_exch_t *exch, int cycles, size_t size, usbdiag_dur_t *duration)
     211{
     212        if (!exch)
     213                return EBADMEM;
     214
     215        sysarg_t duration_;
     216        const int rc = async_req_3_1(exch, DEV_IFACE_ID(USBDIAG_DEV_IFACE), IPC_M_USBDIAG_DATA_ISOCH_IN, cycles, size, &duration_);
     217
     218        if (rc == EOK && duration)
     219                *duration = duration_;
     220
     221        return rc;
     222}
     223
     224int usbdiag_data_isoch_out(async_exch_t *exch, int cycles, size_t size, usbdiag_dur_t *duration)
     225{
     226        if (!exch)
     227                return EBADMEM;
     228
     229        sysarg_t duration_;
     230        const int rc = async_req_3_1(exch, DEV_IFACE_ID(USBDIAG_DEV_IFACE), IPC_M_USBDIAG_DATA_ISOCH_OUT, cycles, size, &duration_);
    141231
    142232        if (rc == EOK && duration)
     
    152242static void remote_usbdiag_burst_isoch_in(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
    153243static void remote_usbdiag_burst_isoch_out(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
     244
     245static void remote_usbdiag_data_intr_in(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
     246static void remote_usbdiag_data_intr_out(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
     247static void remote_usbdiag_data_bulk_in(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
     248static void remote_usbdiag_data_bulk_out(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
     249static void remote_usbdiag_data_isoch_in(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
     250static void remote_usbdiag_data_isoch_out(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
    154251
    155252/** Remote USB diagnostic interface operations. */
     
    160257        [IPC_M_USBDIAG_BURST_BULK_OUT] = remote_usbdiag_burst_bulk_out,
    161258        [IPC_M_USBDIAG_BURST_ISOCH_IN] = remote_usbdiag_burst_isoch_in,
    162         [IPC_M_USBDIAG_BURST_ISOCH_OUT] = remote_usbdiag_burst_isoch_out
     259        [IPC_M_USBDIAG_BURST_ISOCH_OUT] = remote_usbdiag_burst_isoch_out,
     260        [IPC_M_USBDIAG_DATA_INTR_IN] = remote_usbdiag_data_intr_in,
     261        [IPC_M_USBDIAG_DATA_INTR_OUT] = remote_usbdiag_data_intr_out,
     262        [IPC_M_USBDIAG_DATA_BULK_IN] = remote_usbdiag_data_bulk_in,
     263        [IPC_M_USBDIAG_DATA_BULK_OUT] = remote_usbdiag_data_bulk_out,
     264        [IPC_M_USBDIAG_DATA_ISOCH_IN] = remote_usbdiag_data_isoch_in,
     265        [IPC_M_USBDIAG_DATA_ISOCH_OUT] = remote_usbdiag_data_isoch_out
    163266};
    164267
     
    295398}
    296399
     400void remote_usbdiag_data_intr_in(ddf_fun_t *fun, void *iface, ipc_callid_t callid, ipc_call_t *call)
     401{
     402        const usbdiag_iface_t *diag_iface = (usbdiag_iface_t *) iface;
     403
     404        if (diag_iface->data_bulk_in == NULL) {
     405                async_answer_0(callid, ENOTSUP);
     406                return;
     407        }
     408
     409        int cycles = DEV_IPC_GET_ARG1(*call);
     410        size_t size = DEV_IPC_GET_ARG2(*call);
     411        usbdiag_dur_t duration;
     412        const int ret = diag_iface->data_intr_in(fun, cycles, size, &duration);
     413
     414        if (ret != EOK) {
     415                async_answer_0(callid, ret);
     416        } else {
     417                async_answer_1(callid, EOK, duration);
     418        }
     419}
     420
     421void remote_usbdiag_data_intr_out(ddf_fun_t *fun, void *iface, ipc_callid_t callid, ipc_call_t *call)
     422{
     423        const usbdiag_iface_t *diag_iface = (usbdiag_iface_t *) iface;
     424
     425        if (diag_iface->data_bulk_out == NULL) {
     426                async_answer_0(callid, ENOTSUP);
     427                return;
     428        }
     429
     430        int cycles = DEV_IPC_GET_ARG1(*call);
     431        size_t size = DEV_IPC_GET_ARG2(*call);
     432        usbdiag_dur_t duration;
     433        const int ret = diag_iface->data_intr_out(fun, cycles, size, &duration);
     434
     435        if (ret != EOK) {
     436                async_answer_0(callid, ret);
     437        } else {
     438                async_answer_1(callid, EOK, duration);
     439        }
     440}
     441
     442void remote_usbdiag_data_bulk_in(ddf_fun_t *fun, void *iface, ipc_callid_t callid, ipc_call_t *call)
     443{
     444        const usbdiag_iface_t *diag_iface = (usbdiag_iface_t *) iface;
     445
     446        if (diag_iface->data_bulk_in == NULL) {
     447                async_answer_0(callid, ENOTSUP);
     448                return;
     449        }
     450
     451        int cycles = DEV_IPC_GET_ARG1(*call);
     452        size_t size = DEV_IPC_GET_ARG2(*call);
     453        usbdiag_dur_t duration;
     454        const int ret = diag_iface->data_bulk_in(fun, cycles, size, &duration);
     455
     456        if (ret != EOK) {
     457                async_answer_0(callid, ret);
     458        } else {
     459                async_answer_1(callid, EOK, duration);
     460        }
     461}
     462
     463void remote_usbdiag_data_bulk_out(ddf_fun_t *fun, void *iface, ipc_callid_t callid, ipc_call_t *call)
     464{
     465        const usbdiag_iface_t *diag_iface = (usbdiag_iface_t *) iface;
     466
     467        if (diag_iface->data_bulk_out == NULL) {
     468                async_answer_0(callid, ENOTSUP);
     469                return;
     470        }
     471
     472        int cycles = DEV_IPC_GET_ARG1(*call);
     473        size_t size = DEV_IPC_GET_ARG2(*call);
     474        usbdiag_dur_t duration;
     475        const int ret = diag_iface->data_bulk_out(fun, cycles, size, &duration);
     476
     477        if (ret != EOK) {
     478                async_answer_0(callid, ret);
     479        } else {
     480                async_answer_1(callid, EOK, duration);
     481        }
     482}
     483
     484void remote_usbdiag_data_isoch_in(ddf_fun_t *fun, void *iface, ipc_callid_t callid, ipc_call_t *call)
     485{
     486        const usbdiag_iface_t *diag_iface = (usbdiag_iface_t *) iface;
     487
     488        if (diag_iface->data_isoch_in == NULL) {
     489                async_answer_0(callid, ENOTSUP);
     490                return;
     491        }
     492
     493        int cycles = DEV_IPC_GET_ARG1(*call);
     494        size_t size = DEV_IPC_GET_ARG2(*call);
     495        usbdiag_dur_t duration;
     496        const int ret = diag_iface->data_isoch_in(fun, cycles, size, &duration);
     497
     498        if (ret != EOK) {
     499                async_answer_0(callid, ret);
     500        } else {
     501                async_answer_1(callid, EOK, duration);
     502        }
     503}
     504
     505void remote_usbdiag_data_isoch_out(ddf_fun_t *fun, void *iface, ipc_callid_t callid, ipc_call_t *call)
     506{
     507        const usbdiag_iface_t *diag_iface = (usbdiag_iface_t *) iface;
     508
     509        if (diag_iface->data_isoch_out == NULL) {
     510                async_answer_0(callid, ENOTSUP);
     511                return;
     512        }
     513
     514        int cycles = DEV_IPC_GET_ARG1(*call);
     515        size_t size = DEV_IPC_GET_ARG2(*call);
     516        usbdiag_dur_t duration;
     517        const int ret = diag_iface->data_isoch_out(fun, cycles, size, &duration);
     518
     519        if (ret != EOK) {
     520                async_answer_0(callid, ret);
     521        } else {
     522                async_answer_1(callid, EOK, duration);
     523        }
     524}
     525
    297526/**
    298527 * @}
  • uspace/lib/drv/include/usbdiag_iface.h

    rbf7b747 r24c8bf8  
    4848async_sess_t *usbdiag_connect(devman_handle_t);
    4949void usbdiag_disconnect(async_sess_t*);
     50
    5051int usbdiag_burst_intr_in(async_exch_t*, int, size_t, usbdiag_dur_t*);
    5152int usbdiag_burst_intr_out(async_exch_t*, int, size_t, usbdiag_dur_t*);
     
    5455int usbdiag_burst_isoch_in(async_exch_t*, int, size_t, usbdiag_dur_t*);
    5556int usbdiag_burst_isoch_out(async_exch_t*, int, size_t, usbdiag_dur_t*);
     57
     58int usbdiag_data_intr_in(async_exch_t*, int, size_t, usbdiag_dur_t*);
     59int usbdiag_data_intr_out(async_exch_t*, int, size_t, usbdiag_dur_t*);
     60int usbdiag_data_bulk_in(async_exch_t*, int, size_t, usbdiag_dur_t*);
     61int usbdiag_data_bulk_out(async_exch_t*, int, size_t, usbdiag_dur_t*);
     62int usbdiag_data_isoch_in(async_exch_t*, int, size_t, usbdiag_dur_t*);
     63int usbdiag_data_isoch_out(async_exch_t*, int, size_t, usbdiag_dur_t*);
    5664
    5765/** USB diagnostic device communication interface. */
     
    6371        int (*burst_isoch_in)(ddf_fun_t*, int, size_t, usbdiag_dur_t*);
    6472        int (*burst_isoch_out)(ddf_fun_t*, int, size_t, usbdiag_dur_t*);
     73        int (*data_intr_in)(ddf_fun_t*, int, size_t, usbdiag_dur_t*);
     74        int (*data_intr_out)(ddf_fun_t*, int, size_t, usbdiag_dur_t*);
     75        int (*data_bulk_in)(ddf_fun_t*, int, size_t, usbdiag_dur_t*);
     76        int (*data_bulk_out)(ddf_fun_t*, int, size_t, usbdiag_dur_t*);
     77        int (*data_isoch_in)(ddf_fun_t*, int, size_t, usbdiag_dur_t*);
     78        int (*data_isoch_out)(ddf_fun_t*, int, size_t, usbdiag_dur_t*);
    6579} usbdiag_iface_t;
    6680
Note: See TracChangeset for help on using the changeset viewer.