Changeset a8723748 in mainline for uspace/drv/bus


Ignore:
Timestamp:
2017-12-15T10:55:09Z (8 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/drv/bus/usb/usbdiag
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • 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);
Note: See TracChangeset for help on using the changeset viewer.