Changeset a8723748 in mainline
- Timestamp:
- 2017-12-15T10:55:09Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 64d138b
- Parents:
- 837d53d
- Location:
- uspace
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/tmon/main.c
r837d53d ra8723748 52 52 } 53 53 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 } 55 61 56 62 return 0; -
uspace/drv/bus/usb/usbdiag/Makefile
r837d53d ra8723748 29 29 USPACE_PREFIX = ../../../.. 30 30 31 LIBS = usbd ev usb drv31 LIBS = usbdiag usbdev usb drv 32 32 33 33 BINARY = usbdiag -
uspace/drv/bus/usb/usbdiag/main.c
r837d53d ra8723748 32 32 /** 33 33 * @file 34 * Main routines of USB d ebugdevice driver.34 * Main routines of USB diagnostic device driver. 35 35 */ 36 36 #include <errno.h> 37 37 #include <usb/debug.h> 38 38 #include <usb/dev/driver.h> 39 #include <usb/diag/diag.h> 39 40 40 41 #include "usbdiag.h" … … 42 43 43 44 #define NAME "usbdiag" 45 46 static 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 } 44 52 45 53 static int device_add(usb_device_t *dev) … … 99 107 } 100 108 101 /** USB debug driver ops. */ 109 static 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 133 static 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. */ 102 147 static const usb_driver_ops_t diag_driver_ops = { 103 148 .device_add = device_add, … … 108 153 }; 109 154 110 /** USB d ebugdriver. */155 /** USB diagnostic driver. */ 111 156 static const usb_driver_t diag_driver = { 112 157 .name = NAME, … … 117 162 int main(int argc, char *argv[]) 118 163 { 119 printf(NAME ": USB d ebugdevice driver.\n");164 printf(NAME ": USB diagnostic device driver.\n"); 120 165 121 166 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); 122 173 123 174 return usb_driver_main(&diag_driver); -
uspace/lib/usbdiag/Makefile
r837d53d ra8723748 29 29 USPACE_PREFIX = ../.. 30 30 LIBRARY = libusbdiag 31 LIBS = usb31 LIBS = drv usb 32 32 33 33 SOURCES = \ -
uspace/lib/usbdiag/include/usb/diag/diag.h
r837d53d ra8723748 36 36 #define LIBUSBDIAG_DIAG_H_ 37 37 38 #include <ipc/common.h> 39 40 typedef enum { 41 USB_DIAG_IN_TEST = IPC_FIRST_USER_METHOD, 42 } usb_diag_in_request_t; 43 38 44 /** Just a dummy symbol to make compiler happy. TODO: remove it */ 39 int usb_diag_test(int );45 int usb_diag_test(int, int*); 40 46 41 47 #endif -
uspace/lib/usbdiag/src/test.c
r837d53d ra8723748 34 34 */ 35 35 36 #include <async.h> 36 37 #include <usb/diag/diag.h> 37 38 38 int usb_diag_test(int x )39 int usb_diag_test(int x, int *out) 39 40 { 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; 41 51 } 42 52
Note:
See TracChangeset
for help on using the changeset viewer.