Changeset b4b534ac in mainline for uspace/app
- Timestamp:
- 2016-07-22T08:24:47Z (10 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f76d2c2
- Parents:
- 5b18137 (diff), 8351f9a4 (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. - Location:
- uspace/app
- Files:
-
- 1 deleted
- 12 edited
-
bdsh/cmds/modules/mount/mount.c (modified) (2 diffs)
-
mkbd/main.c (modified) (2 diffs)
-
usbinfo/Makefile (modified) (1 diff)
-
usbinfo/dev.c (deleted)
-
usbinfo/hid.c (modified) (3 diffs)
-
usbinfo/info.c (modified) (9 diffs)
-
usbinfo/list.c (modified) (3 diffs)
-
usbinfo/main.c (modified) (4 diffs)
-
usbinfo/usbinfo.h (modified) (3 diffs)
-
vuhid/device.c (modified) (2 diffs)
-
vuhid/hids/bootkbd.c (modified) (1 diff)
-
vuhid/main.c (modified) (6 diffs)
-
vuhid/virthid.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/bdsh/cmds/modules/mount/mount.c
r5b18137 rb4b534ac 30 30 #include <stdio.h> 31 31 #include <stdlib.h> 32 #include <str_error.h> 32 33 #include <vfs/vfs.h> 33 34 #include <adt/list.h> … … 152 153 rc = vfs_mount(t_argv[1], t_argv[2], dev, mopts, 0, instance); 153 154 if (rc != EOK) { 154 printf("Unable to mount %s filesystem to %s on %s (rc=% d)\n",155 t_argv[1], t_argv[2], t_argv[3], rc);155 printf("Unable to mount %s filesystem to %s on %s (rc=%s)\n", 156 t_argv[1], t_argv[2], t_argv[3], str_error(rc)); 156 157 return CMD_FAILURE; 157 158 } -
uspace/app/mkbd/main.c
r5b18137 rb4b534ac 44 44 #include <devman.h> 45 45 #include <loc.h> 46 #include <usb/dev/hub.h>47 46 #include <usbhid_iface.h> 48 47 #include <usb/dev/pipes.h> … … 219 218 devman_handle_t dev_handle = 0; 220 219 221 int rc = usb_resolve_device_handle(devpath, NULL, NULL,&dev_handle);220 int rc = usb_resolve_device_handle(devpath, &dev_handle); 222 221 if (rc != EOK) { 223 222 printf("Device not found or not of USB kind: %s.\n", -
uspace/app/usbinfo/Makefile
r5b18137 rb4b534ac 43 43 SOURCES = \ 44 44 desctree.c \ 45 dev.c \46 45 dump.c \ 47 46 hid.c \ -
uspace/app/usbinfo/hid.c
r5b18137 rb4b534ac 36 36 #include <stdio.h> 37 37 #include <str_error.h> 38 #include <usb/debug.h> 38 39 #include <usb/classes/classes.h> 39 40 #include <usb/dev/request.h> … … 50 51 51 52 typedef struct { 52 usb info_device_t *dev;53 usb_device_t *usb_dev; 53 54 hid_dump_type_t dump_type; 54 55 usb_standard_interface_descriptor_t *last_iface; … … 211 212 212 213 retrieve_and_dump_hid_report(context->dump_type, 213 &context->dev->ctrl_pipe, context->last_iface->interface_number,214 report_size);215 } 216 217 218 void dump_hidreport_raw(usb info_device_t *dev)214 usb_device_get_default_pipe(context->usb_dev), 215 context->last_iface->interface_number, report_size); 216 } 217 218 219 void dump_hidreport_raw(usb_device_t *usb_dev) 219 220 { 220 221 descriptor_walk_context_t context = { 221 . dev =dev,222 .usb_dev = usb_dev, 222 223 .dump_type = HID_DUMP_RAW, 223 224 .last_iface = NULL 224 225 }; 225 226 226 usb_dp_walk_simple(dev->full_configuration_descriptor, 227 dev->full_configuration_descriptor_size, 227 usb_dp_walk_simple( 228 usb_device_descriptors(usb_dev)->full_config, 229 usb_device_descriptors(usb_dev)->full_config_size, 228 230 usb_dp_standard_descriptor_nesting, 229 231 descriptor_walk_callback, &context); 230 232 } 231 233 232 void dump_hidreport_usages(usb info_device_t *dev)234 void dump_hidreport_usages(usb_device_t *usb_dev) 233 235 { 234 236 descriptor_walk_context_t context = { 235 . dev =dev,237 .usb_dev = usb_dev, 236 238 .dump_type = HID_DUMP_USAGES, 237 239 .last_iface = NULL 238 240 }; 239 241 240 usb_dp_walk_simple(dev->full_configuration_descriptor, 241 dev->full_configuration_descriptor_size, 242 usb_dp_walk_simple( 243 usb_device_descriptors(usb_dev)->full_config, 244 usb_device_descriptors(usb_dev)->full_config_size, 242 245 usb_dp_standard_descriptor_nesting, 243 246 descriptor_walk_callback, &context); -
uspace/app/usbinfo/info.c
r5b18137 rb4b534ac 37 37 #include <str_error.h> 38 38 #include <errno.h> 39 #include <usb/debug.h> 39 40 #include <usb/dev/pipes.h> 40 41 #include <usb/dev/recognise.h> … … 44 45 #include "usbinfo.h" 45 46 46 void dump_short_device_identification(usb info_device_t *dev)47 void dump_short_device_identification(usb_device_t *usb_dev) 47 48 { 48 49 printf("%sDevice 0x%04x by vendor 0x%04x\n", get_indent(0), 49 (int) dev->device_descriptor.product_id,50 (int) dev->device_descriptor.vendor_id);50 usb_device_descriptors(usb_dev)->device.product_id, 51 usb_device_descriptors(usb_dev)->device.vendor_id); 51 52 } 52 53 … … 66 67 } 67 68 68 usbinfo_device_t *dev = (usbinfo_device_t *) arg; 69 usb_device_t *usb_dev = arg; 70 assert(usb_dev); 69 71 70 72 usb_standard_interface_descriptor_t *iface … … 80 82 match_id_list_t matches; 81 83 init_match_ids(&matches); 82 usb_device_create_match_ids_from_interface( &dev->device_descriptor,83 iface, &matches);84 usb_device_create_match_ids_from_interface( 85 &usb_device_descriptors(usb_dev)->device, iface, &matches); 84 86 dump_match_ids(&matches, get_indent(1)); 85 87 clean_match_ids(&matches); 86 88 } 87 89 88 void dump_device_match_ids(usb info_device_t *dev)90 void dump_device_match_ids(usb_device_t *usb_dev) 89 91 { 90 92 match_id_list_t matches; 91 93 init_match_ids(&matches); 92 94 usb_device_create_match_ids_from_device_descriptor( 93 &dev->device_descriptor, &matches);95 &usb_device_descriptors(usb_dev)->device, &matches); 94 96 printf("%sDevice match ids (0x%04x by 0x%04x, %s)\n", get_indent(0), 95 (int) dev->device_descriptor.product_id,96 (int) dev->device_descriptor.vendor_id,97 usb_str_class( dev->device_descriptor.device_class));97 usb_device_descriptors(usb_dev)->device.product_id, 98 usb_device_descriptors(usb_dev)->device.vendor_id, 99 usb_str_class(usb_device_descriptors(usb_dev)->device.device_class)); 98 100 dump_match_ids(&matches, get_indent(1)); 99 101 clean_match_ids(&matches); 100 102 101 usb_dp_walk_simple(dev->full_configuration_descriptor, 102 dev->full_configuration_descriptor_size, 103 usb_dp_walk_simple( 104 usb_device_descriptors(usb_dev)->full_config, 105 usb_device_descriptors(usb_dev)->full_config_size, 103 106 usb_dp_standard_descriptor_nesting, 104 dump_match_ids_from_interface, 105 dev); 107 dump_match_ids_from_interface, usb_dev); 106 108 } 107 109 … … 224 226 } 225 227 226 void dump_descriptor_tree_brief(usbinfo_device_t *dev) 227 { 228 dump_descriptor_tree_callback((uint8_t *)&dev->device_descriptor, 228 void dump_descriptor_tree_brief(usb_device_t *usb_dev) 229 { 230 dump_descriptor_tree_callback( 231 (const uint8_t *)&usb_device_descriptors(usb_dev)->device, 229 232 (size_t) -1, NULL); 230 usb_dp_walk_simple(dev->full_configuration_descriptor, 231 dev->full_configuration_descriptor_size, 233 234 usb_dp_walk_simple( 235 usb_device_descriptors(usb_dev)->full_config, 236 usb_device_descriptors(usb_dev)->full_config_size, 232 237 usb_dp_standard_descriptor_nesting, 233 dump_descriptor_tree_callback, 234 NULL); 235 } 236 237 void dump_descriptor_tree_full(usbinfo_device_t *dev) 238 { 239 dump_descriptor_tree_callback((uint8_t *)&dev->device_descriptor, 240 (size_t) -1, dev); 241 usb_dp_walk_simple(dev->full_configuration_descriptor, 242 dev->full_configuration_descriptor_size, 238 dump_descriptor_tree_callback, NULL); 239 } 240 241 void dump_descriptor_tree_full(usb_device_t *usb_dev) 242 { 243 dump_descriptor_tree_callback( 244 (const uint8_t *)&usb_device_descriptors(usb_dev)->device, 245 (size_t) -1, usb_dev); 246 247 usb_dp_walk_simple( 248 usb_device_descriptors(usb_dev)->full_config, 249 usb_device_descriptors(usb_dev)->full_config_size, 243 250 usb_dp_standard_descriptor_nesting, 244 dump_descriptor_tree_callback, 245 dev); 251 dump_descriptor_tree_callback, usb_dev); 246 252 } 247 253 … … 285 291 286 292 287 void dump_strings(usb info_device_t *dev)293 void dump_strings(usb_device_t *usb_dev) 288 294 { 289 295 /* Find used indexes. Devices with more than 64 strings are very rare.*/ 290 296 uint64_t str_mask = 0; 291 find_string_indexes_callback((uint8_t *)&dev->device_descriptor, 0, 297 find_string_indexes_callback( 298 (const uint8_t *)&usb_device_descriptors(usb_dev)->device, 0, 292 299 &str_mask); 293 usb_dp_walk_simple(dev->full_configuration_descriptor, 294 dev->full_configuration_descriptor_size, 300 301 usb_dp_walk_simple( 302 usb_device_descriptors(usb_dev)->full_config, 303 usb_device_descriptors(usb_dev)->full_config_size, 295 304 usb_dp_standard_descriptor_nesting, 296 find_string_indexes_callback, 297 &str_mask); 305 find_string_indexes_callback, &str_mask); 298 306 299 307 if (str_mask == 0) { … … 305 313 l18_win_locales_t *langs; 306 314 size_t langs_count; 307 int rc = usb_request_get_supported_languages( &dev->ctrl_pipe,308 &langs, &langs_count);315 int rc = usb_request_get_supported_languages( 316 usb_device_get_default_pipe(usb_dev), &langs, &langs_count); 309 317 if (rc != EOK) { 310 318 fprintf(stderr, … … 334 342 } 335 343 char *string = NULL; 336 rc = usb_request_get_string(&dev->ctrl_pipe, idx, lang, 344 rc = usb_request_get_string( 345 usb_device_get_default_pipe(usb_dev), idx, lang, 337 346 &string); 338 347 if ((rc != EOK) && (rc != EEMPTY)) { … … 351 360 352 361 353 void dump_status(usb info_device_t *dev)362 void dump_status(usb_device_t *usb_dev) 354 363 { 355 364 int rc; 356 uint16_t device_status = 0; 357 uint16_t ctrl_pipe_status = 0; 365 uint16_t status = 0; 358 366 359 367 /* Device status first. */ 360 rc = usb_request_get_status(&dev->ctrl_pipe, 361 USB_REQUEST_RECIPIENT_DEVICE, 0, 362 &device_status); 368 rc = usb_request_get_status(usb_device_get_default_pipe(usb_dev), 369 USB_REQUEST_RECIPIENT_DEVICE, 0, &status); 363 370 if (rc != EOK) { 364 371 printf("%sFailed to get device status: %s.\n", 365 372 get_indent(0), str_error(rc)); 366 goto try_ctrl_pipe_status; 367 } 368 369 printf("%sDevice status 0x%04x: power=%s, remote-wakeup=%s.\n", 370 get_indent(0), 371 device_status, 372 device_status & USB_DEVICE_STATUS_SELF_POWERED ? "self" : "bus", 373 device_status & USB_DEVICE_STATUS_REMOTE_WAKEUP ? "yes" : "no"); 373 } else { 374 printf("%sDevice status 0x%04x: power=%s, remote-wakeup=%s.\n", 375 get_indent(0), status, 376 status & USB_DEVICE_STATUS_SELF_POWERED ? "self" : "bus", 377 status & USB_DEVICE_STATUS_REMOTE_WAKEUP ? "yes" : "no"); 378 } 374 379 375 380 /* Interface is not interesting, skipping ;-). */ 376 381 377 382 /* Control endpoint zero. */ 378 try_ctrl_pipe_status: 379 rc = usb_request_get_status(&dev->ctrl_pipe, 380 USB_REQUEST_RECIPIENT_ENDPOINT, 0, 381 &ctrl_pipe_status); 383 status = 0; 384 rc = usb_request_get_status(usb_device_get_default_pipe(usb_dev), 385 USB_REQUEST_RECIPIENT_ENDPOINT, 0, &status); 382 386 if (rc != EOK) { 383 387 printf("%sFailed to get control endpoint status: %s.\n", 384 388 get_indent(0), str_error(rc)); 385 goto leave; 386 } 387 388 printf("%sControl endpoint zero status %04X: halted=%s.\n", 389 get_indent(0), 390 ctrl_pipe_status, 391 ctrl_pipe_status & USB_ENDPOINT_STATUS_HALTED ? "yes" : "no"); 392 393 leave: 394 return; 389 } else { 390 printf("%sControl endpoint zero status %04X: halted=%s.\n", 391 get_indent(0), status, 392 status & USB_ENDPOINT_STATUS_HALTED ? "yes" : "no"); 393 } 395 394 } 396 395 -
uspace/app/usbinfo/list.c
r5b18137 rb4b534ac 44 44 #include <devman.h> 45 45 #include <loc.h> 46 #include <usb/dev/hub.h> 47 #include <usb/hc.h> 46 #include <usb_iface.h> 48 47 49 48 #include "usbinfo.h" 50 49 51 #define MAX_USB_ADDRESS USB11_ADDRESS_MAX52 50 #define MAX_PATH_LENGTH 1024 53 51 54 static void print_ found_hc(service_id_t sid, const char *path)52 static void print_usb_device(devman_handle_t handle) 55 53 { 56 printf("Bus %" PRIun ": %s\n", sid, path); 57 } 58 static void print_found_dev(usb_address_t addr, const char *path) 59 { 60 printf(" Device %02d: %s\n", addr, path); 54 char path[MAX_PATH_LENGTH]; 55 int rc = devman_fun_get_path(handle, path, MAX_PATH_LENGTH); 56 if (rc != EOK) { 57 printf(NAME "Failed to get path for device %"PRIun"\n", handle); 58 return; 59 } 60 printf("\tDevice %" PRIun ": %s\n", handle, path); 61 61 } 62 62 63 static void print_ hc_devices(devman_handle_t hc_handle)63 static void print_usb_bus(service_id_t svc) 64 64 { 65 int rc; 66 usb_hc_connection_t conn; 67 68 usb_hc_connection_initialize(&conn, hc_handle); 69 rc = usb_hc_connection_open(&conn); 65 devman_handle_t hc_handle = 0; 66 int rc = devman_fun_sid_to_handle(svc, &hc_handle); 70 67 if (rc != EOK) { 71 printf(NAME ": failed to connect to HC: %s.\n",72 str_error(rc));68 printf(NAME ": Error resolving handle of HC with SID %" 69 PRIun ", skipping.\n", svc); 73 70 return; 74 71 } 75 usb_address_t addr; 76 for (addr = 1; addr < MAX_USB_ADDRESS; addr++) { 77 devman_handle_t dev_handle; 78 rc = usb_hc_get_handle_by_address(&conn, addr, &dev_handle); 79 if (rc != EOK) { 80 continue; 81 } 82 char path[MAX_PATH_LENGTH]; 83 rc = devman_fun_get_path(dev_handle, path, MAX_PATH_LENGTH); 84 if (rc != EOK) { 85 continue; 86 } 87 print_found_dev(addr, path); 72 73 char path[MAX_PATH_LENGTH]; 74 rc = devman_fun_get_path(hc_handle, path, sizeof(path)); 75 if (rc != EOK) { 76 printf(NAME ": Error resolving path of HC with SID %" 77 PRIun ", skipping.\n", svc); 78 return; 88 79 } 89 usb_hc_connection_close(&conn); 80 printf("Bus %" PRIun ": %s\n", svc, path); 81 82 /* Construct device's path. 83 * That's "hc function path" - ( '/' + "hc function name" ) */ 84 // TODO replace this with something sane 85 86 /* Get function name */ 87 char name[10]; 88 rc = devman_fun_get_name(hc_handle, name, sizeof(name)); 89 if (rc != EOK) { 90 printf(NAME ": Error resolving name of HC with SID %" 91 PRIun ", skipping.\n", svc); 92 return; 93 } 94 95 /* Get handle of parent device */ 96 devman_handle_t fh; 97 path[str_size(path) - str_size(name) - 1] = '\0'; 98 rc = devman_fun_get_handle(path, &fh, IPC_FLAG_BLOCKING); 99 if (rc != EOK) { 100 printf(NAME ": Error resolving parent handle of HC with" 101 " SID %" PRIun ", skipping.\n", svc); 102 return; 103 } 104 105 /* Get child handle */ 106 devman_handle_t dh; 107 rc = devman_fun_get_child(fh, &dh); 108 if (rc != EOK) { 109 printf(NAME ": Error resolving parent handle of HC with" 110 " SID %" PRIun ", skipping.\n", svc); 111 return; 112 } 113 114 devman_handle_t *fhs = 0; 115 size_t count; 116 rc = devman_dev_get_functions(dh, &fhs, &count); 117 if (rc != EOK) { 118 printf(NAME ": Error siblings of HC with" 119 " SID %" PRIun ", skipping.\n", svc); 120 return; 121 } 122 123 for (size_t i = 0; i < count; ++i) { 124 if (fhs[i] != hc_handle) 125 print_usb_device(fhs[i]); 126 } 127 free(fhs); 90 128 } 91 129 … … 95 133 service_id_t *svcs; 96 134 size_t count; 97 size_t i;98 135 int rc; 99 136 … … 111 148 } 112 149 113 for (i = 0; i < count; i++) { 114 devman_handle_t hc_handle = 0; 115 int rc = usb_ddf_get_hc_handle_by_sid(svcs[i], &hc_handle); 116 if (rc != EOK) { 117 printf(NAME ": Error resolving handle of HC with SID %" 118 PRIun ", skipping.\n", svcs[i]); 119 continue; 120 } 121 char path[MAX_PATH_LENGTH]; 122 rc = devman_fun_get_path(hc_handle, path, MAX_PATH_LENGTH); 123 if (rc != EOK) { 124 printf(NAME ": Error resolving path of HC with SID %" 125 PRIun ", skipping.\n", svcs[i]); 126 continue; 127 } 128 print_found_hc(svcs[i], path); 129 print_hc_devices(hc_handle); 150 for (unsigned i = 0; i < count; ++i) { 151 print_usb_bus(svcs[i]); 130 152 } 131 153 -
uspace/app/usbinfo/main.c
r5b18137 rb4b534ac 43 43 #include <devman.h> 44 44 #include <loc.h> 45 #include <usb/hc.h>46 45 #include <usb/dev.h> 47 46 #include <usb/dev/pipes.h> … … 198 197 199 198 /* The initialization is here only to make compiler happy. */ 200 devman_handle_t hc_handle = 0; 201 usb_address_t dev_addr = 0; 202 int rc = usb_resolve_device_handle(devpath, 203 &hc_handle, &dev_addr, NULL); 199 devman_handle_t handle = 0; 200 int rc = usb_resolve_device_handle(devpath, &handle); 204 201 if (rc != EOK) { 205 202 fprintf(stderr, NAME ": device `%s' not found " … … 209 206 } 210 207 211 usbinfo_device_t *dev = prepare_device(devpath, 212 hc_handle, dev_addr); 213 if (dev == NULL) { 208 usb_device_t *usb_dev = usb_device_create(handle); 209 210 if (usb_dev == NULL) { 211 fprintf(stderr, NAME ": device `%s' not found " 212 "or not of USB kind, skipping.\n", 213 devpath); 214 214 continue; 215 215 } … … 221 221 while (actions[action].opt != 0) { 222 222 if (actions[action].active) { 223 actions[action].action( dev);223 actions[action].action(usb_dev); 224 224 } 225 225 action++; 226 226 } 227 227 228 /* Destroy the control pipe (close the session etc.). */ 229 destroy_device(dev); 228 usb_device_destroy(usb_dev); 230 229 } 231 230 -
uspace/app/usbinfo/usbinfo.h
r5b18137 rb4b534ac 38 38 #include <usb/usb.h> 39 39 #include <usb/descriptor.h> 40 #include <usb/dev/pipes.h> 41 #include <usb/debug.h> 40 #include <usb/dev/device.h> 42 41 #include <usb/dev/dp.h> 43 42 #include <ipc/devman.h> 44 43 45 44 typedef struct { 46 usb_hc_connection_t hc_conn;47 usb_device_connection_t wire;48 usb_pipe_t ctrl_pipe;49 usb_standard_device_descriptor_t device_descriptor;50 uint8_t *full_configuration_descriptor;51 size_t full_configuration_descriptor_size;52 } usbinfo_device_t;53 54 typedef struct {55 45 int opt; 56 void (*action)(usb info_device_t *dev);46 void (*action)(usb_device_t *usb_dev); 57 47 bool active; 58 48 } usbinfo_action_t; … … 72 62 } 73 63 74 usbinfo_device_t *prepare_device(const char *, devman_handle_t, usb_address_t);75 void destroy_device(usbinfo_device_t *);76 77 64 typedef void (*dump_descriptor_in_tree_t)(const uint8_t *, size_t, void *); 78 65 void browse_descriptor_tree(uint8_t *, size_t, usb_dp_descriptor_nesting_t *, … … 81 68 void list(void); 82 69 83 void dump_short_device_identification(usbinfo_device_t *); 84 void dump_device_match_ids(usbinfo_device_t *); 85 void dump_descriptor_tree_brief(usbinfo_device_t *); 86 void dump_descriptor_tree_full(usbinfo_device_t *); 87 void dump_strings(usbinfo_device_t *); 88 void dump_status(usbinfo_device_t *); 89 void dump_hidreport_raw(usbinfo_device_t *); 90 void dump_hidreport_usages(usbinfo_device_t *); 91 70 void dump_short_device_identification(usb_device_t *); 71 void dump_device_match_ids(usb_device_t *); 72 void dump_descriptor_tree_brief(usb_device_t *); 73 void dump_descriptor_tree_full(usb_device_t *); 74 void dump_strings(usb_device_t *); 75 void dump_status(usb_device_t *); 76 void dump_hidreport_raw(usb_device_t *); 77 void dump_hidreport_usages(usb_device_t *); 92 78 93 79 #endif -
uspace/app/vuhid/device.c
r5b18137 rb4b534ac 60 60 static int on_data_to_device(usbvirt_device_t *dev, 61 61 usb_endpoint_t ep, usb_transfer_type_t tr_type, 62 void *data, size_t data_size)62 const void *data, size_t data_size) 63 63 { 64 64 vuhid_data_t *vuhid = dev->device_data; … … 254 254 255 255 /* Extend existing extra descriptors with these ones. */ 256 usbvirt_device_configuration_extras_t *extra_descriptors 257 = dev->descriptors->configuration->extra; 258 extra_descriptors = realloc(extra_descriptors, 256 usbvirt_device_configuration_extras_t *extra_descriptors; 257 extra_descriptors = realloc(dev->descriptors->configuration->extra, 259 258 sizeof(usbvirt_device_configuration_extras_t) 260 259 * (dev->descriptors->configuration->extra_count + descr_count)); -
uspace/app/vuhid/hids/bootkbd.c
r5b18137 rb4b534ac 102 102 103 103 static int on_data_out(vuhid_interface_t *iface, 104 void *buffer, size_t buffer_size)104 const void *buffer, size_t buffer_size) 105 105 { 106 106 if (buffer_size == 0) { -
uspace/app/vuhid/main.c
r5b18137 rb4b534ac 40 40 #include <errno.h> 41 41 #include <str_error.h> 42 #include <getopt.h> 42 43 43 44 #include <usb/usb.h> … … 52 53 #include "stdreq.h" 53 54 55 #define DEFAULT_CONTROLLER "/virt/usbhc/virtual" 56 54 57 static usbvirt_control_request_handler_t endpoint_zero_handlers[] = { 55 58 { 56 .req_direction = USB_DIRECTION_IN, 57 .req_type = USB_REQUEST_TYPE_STANDARD, 58 .req_recipient = USB_REQUEST_RECIPIENT_INTERFACE, 59 .request = USB_DEVREQ_GET_DESCRIPTOR, 59 STD_REQ_IN(USB_REQUEST_RECIPIENT_INTERFACE, USB_DEVREQ_GET_DESCRIPTOR), 60 60 .name = "Get_Descriptor", 61 61 .callback = req_get_descriptor 62 62 }, 63 63 { 64 .req_direction = USB_DIRECTION_OUT, 65 .req_recipient = USB_REQUEST_RECIPIENT_INTERFACE, 66 .req_type = USB_REQUEST_TYPE_CLASS, 67 .request = USB_HIDREQ_SET_PROTOCOL, 64 CLASS_REQ_OUT(USB_REQUEST_RECIPIENT_INTERFACE, USB_HIDREQ_SET_PROTOCOL), 68 65 .name = "Set_Protocol", 69 66 .callback = req_set_protocol 70 67 }, 71 68 { 72 .req_direction = USB_DIRECTION_OUT, 73 .req_recipient = USB_REQUEST_RECIPIENT_INTERFACE, 74 .req_type = USB_REQUEST_TYPE_CLASS, 75 .request = USB_HIDREQ_SET_REPORT, 69 CLASS_REQ_OUT(USB_REQUEST_RECIPIENT_INTERFACE, USB_HIDREQ_SET_REPORT), 76 70 .name = "Set_Report", 77 71 .callback = req_set_report … … 151 145 152 146 147 static struct option long_options[] = { 148 {"help", optional_argument, NULL, 'h'}, 149 {"controller", required_argument, NULL, 'c' }, 150 {"list", no_argument, NULL, 'l' }, 151 {0, 0, NULL, 0} 152 }; 153 static const char *short_options = "hc:l"; 154 155 static void print_help(const char* name, const char* module) 156 { 157 if (module == NULL) { 158 /* Default help */ 159 printf("Usage: %s [options] device.\n", name); 160 printf("\t-h, --help [device]\n"); 161 printf("\t\to With no argument print this help and exit.\n"); 162 printf("\t\to With argument print device specific help and exit.\n"); 163 printf("\t-l, --list \n\t\tPrint list of available devices.\n"); 164 printf("\t-c, --controller \n\t\t" 165 "Use provided virtual hc instead of default (%s)\n", 166 DEFAULT_CONTROLLER); 167 return; 168 } 169 printf("HELP for module %s\n", module); 170 } 171 172 static void print_list(void) 173 { 174 printf("Available devices:\n"); 175 for (vuhid_interface_t **i = available_hid_interfaces; *i != NULL; ++i) 176 { 177 printf("\t`%s'\t%s\n", (*i)->id, (*i)->name); 178 } 179 180 } 181 182 static const char *controller = DEFAULT_CONTROLLER; 183 153 184 int main(int argc, char * argv[]) 154 185 { 155 int rc; 186 187 if (argc == 1) { 188 print_help(*argv, NULL); 189 return 0; 190 } 191 192 int opt = 0; 193 while ((opt = getopt_long(argc, argv, short_options, long_options, NULL)) > 0) { 194 switch (opt) 195 { 196 case 'h': 197 print_help(*argv, optarg); 198 return 0; 199 case 'c': 200 controller = optarg; 201 break; 202 case 'l': 203 print_list(); 204 return 0; 205 case -1: 206 default: 207 break; 208 } 209 } 210 156 211 157 212 log_init("vuhid"); … … 161 216 162 217 /* Determine which interfaces to initialize. */ 163 int i; 164 for (i = 1; i < argc; i++) { 165 rc = add_interface_by_id(available_hid_interfaces, argv[i], 218 for (int i = optind; i < argc; i++) { 219 int rc = add_interface_by_id(available_hid_interfaces, argv[i], 166 220 &hid_dev); 167 221 if (rc != EOK) { … … 173 227 } 174 228 175 for (i = 0; i < (int) hid_dev.descriptors->configuration->extra_count; i++) {229 for (int i = 0; i < (int) hid_dev.descriptors->configuration->extra_count; i++) { 176 230 usb_log_debug("Found extra descriptor: %s.\n", 177 231 usb_debug_str_buffer( … … 181 235 } 182 236 183 rc = usbvirt_device_plug(&hid_dev, "/virt/usbhc/hc");237 const int rc = usbvirt_device_plug(&hid_dev, controller); 184 238 if (rc != EOK) { 185 printf("Unable to start communication with VHCD : %s.\n",186 str_error(rc));239 printf("Unable to start communication with VHCD `%s': %s.\n", 240 controller, str_error(rc)); 187 241 return rc; 188 242 } 189 243 190 printf("Connected to VHCD ...\n");244 printf("Connected to VHCD `%s'...\n", controller); 191 245 192 246 wait_for_interfaces_death(&hid_dev); -
uspace/app/vuhid/virthid.h
r5b18137 rb4b534ac 71 71 72 72 int (*on_data_in)(vuhid_interface_t *, void *, size_t, size_t *); 73 int (*on_data_out)(vuhid_interface_t *, void *, size_t);73 int (*on_data_out)(vuhid_interface_t *, const void *, size_t); 74 74 void (*live)(vuhid_interface_t *); 75 75
Note:
See TracChangeset
for help on using the changeset viewer.
