Changeset a8723748 in mainline


Ignore:
Timestamp:
2017-12-15T10:55:09Z (6 years ago)
Author:
Petr Mánek <petr.manek@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
64d138b
Parents:
837d53d
Message:

usbdiag: add server, dummy stubs and skeletons

Location:
uspace
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/tmon/main.c

    r837d53d ra8723748  
    5252        }
    5353
    54         printf("The number is %d.\n", usb_diag_test(0));
     54        int out;
     55        const int rc = usb_diag_test(0, &out);
     56        if (rc) {
     57                printf("Error: %d\n", rc);
     58        } else {
     59                printf("The number is %d.\n", out);
     60        }
    5561
    5662        return 0;
  • uspace/drv/bus/usb/usbdiag/Makefile

    r837d53d ra8723748  
    2929USPACE_PREFIX = ../../../..
    3030
    31 LIBS = usbdev usb drv
     31LIBS = usbdiag usbdev usb drv
    3232
    3333BINARY = usbdiag
  • uspace/drv/bus/usb/usbdiag/main.c

    r837d53d ra8723748  
    3232/**
    3333 * @file
    34  * Main routines of USB debug device driver.
     34 * Main routines of USB diagnostic device driver.
    3535 */
    3636#include <errno.h>
    3737#include <usb/debug.h>
    3838#include <usb/dev/driver.h>
     39#include <usb/diag/diag.h>
    3940
    4041#include "usbdiag.h"
     
    4243
    4344#define NAME "usbdiag"
     45
     46static void usb_diag_test_impl(ipc_callid_t rid, ipc_call_t *request)
     47{
     48        int x = IPC_GET_ARG1(*request);
     49        int ret = 4200 + x;
     50        async_answer_0(rid, ret);
     51}
    4452
    4553static int device_add(usb_device_t *dev)
     
    99107}
    100108
    101 /** USB debug driver ops. */
     109static void connection(ipc_callid_t iid, ipc_call_t *icall, void *arg)
     110{
     111        bool cont = true;
     112
     113        async_answer_0(iid, EOK);
     114
     115        while (cont) {
     116                ipc_call_t call;
     117                ipc_callid_t callid = async_get_call(&call);
     118
     119                if (!IPC_GET_IMETHOD(call))
     120                        break;
     121
     122                switch (IPC_GET_IMETHOD(call)) {
     123                case USB_DIAG_IN_TEST:
     124                        usb_diag_test_impl(callid, &call);
     125                        break;
     126                default:
     127                        async_answer_0(callid, ENOTSUP);
     128                        break;
     129                }
     130        }
     131}
     132
     133static int server_fibril(void *arg)
     134{
     135        // async_set_client_data_constructor(NULL);
     136        // async_set_client_data_destructor(NULL);
     137        async_set_fallback_port_handler(connection, NULL);
     138        // async_event_task_subscribe();
     139        // service_register();
     140        async_manager();
     141
     142        /* Never reached. */
     143        return EOK;
     144}
     145
     146/** USB diagnostic driver ops. */
    102147static const usb_driver_ops_t diag_driver_ops = {
    103148        .device_add = device_add,
     
    108153};
    109154
    110 /** USB debug driver. */
     155/** USB diagnostic driver. */
    111156static const usb_driver_t diag_driver = {
    112157        .name = NAME,
     
    117162int main(int argc, char *argv[])
    118163{
    119         printf(NAME ": USB debug device driver.\n");
     164        printf(NAME ": USB diagnostic device driver.\n");
    120165
    121166        log_init(NAME);
     167
     168        /* Start usbdiag service. */
     169        fid_t srv = fibril_create(server_fibril, NULL);
     170        if (!srv)
     171                return ENOMEM;
     172        fibril_add_ready(srv);
    122173
    123174        return usb_driver_main(&diag_driver);
  • uspace/lib/usbdiag/Makefile

    r837d53d ra8723748  
    2929USPACE_PREFIX = ../..
    3030LIBRARY = libusbdiag
    31 LIBS = usb
     31LIBS = drv usb
    3232
    3333SOURCES = \
  • uspace/lib/usbdiag/include/usb/diag/diag.h

    r837d53d ra8723748  
    3636#define LIBUSBDIAG_DIAG_H_
    3737
     38#include <ipc/common.h>
     39
     40typedef enum {
     41  USB_DIAG_IN_TEST = IPC_FIRST_USER_METHOD,
     42} usb_diag_in_request_t;
     43
    3844/** Just a dummy symbol to make compiler happy. TODO: remove it */
    39 int usb_diag_test(int);
     45int usb_diag_test(int, int*);
    4046
    4147#endif
  • uspace/lib/usbdiag/src/test.c

    r837d53d ra8723748  
    3434 */
    3535
     36#include <async.h>
    3637#include <usb/diag/diag.h>
    3738
    38 int usb_diag_test(int x)
     39int usb_diag_test(int x, int *out)
    3940{
    40         return x + 42;
     41        sysarg_t _out;
     42        async_sess_t *session = NULL;
     43        async_exch_t *exch = async_exchange_begin(session);
     44        const int rc = async_req_1_1(exch, USB_DIAG_IN_TEST, x, &_out);
     45        async_exchange_end(exch);
     46
     47        if (out)
     48                *out = (int) _out;
     49
     50        return rc;
    4151}
    4252
Note: See TracChangeset for help on using the changeset viewer.