Changeset d5e7668 in mainline
- Timestamp:
- 2010-12-13T14:56:16Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 266d0871
- Parents:
- 76daaf9f
- Location:
- uspace
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/virtusbkbd/virtusbkbd.c
r76daaf9f rd5e7668 138 138 USBVIRT_REQUEST_RECIPIENT_DEVICE), 139 139 .request = USB_DEVREQ_GET_DESCRIPTOR, 140 .name = "GetDescriptor", 140 141 .callback = stdreq_on_get_descriptor 141 142 }, … … 146 147 USBVIRT_REQUEST_RECIPIENT_DEVICE), 147 148 .request = USB_DEVREQ_GET_DESCRIPTOR, 149 .name = "GetDescriptor", 148 150 .callback = stdreq_on_get_descriptor 149 151 }, … … 268 270 269 271 printf("%s: Simulating keyboard events...\n", NAME); 272 fibril_sleep(10); 270 273 while (1) { 271 274 kb_process_events(&status, keyboard_events, keyboard_events_count, -
uspace/drv/vhc/hubops.c
r76daaf9f rd5e7668 519 519 { 520 520 STD_REQ(DIR_OUT, REC_DEVICE, USB_DEVREQ_SET_CONFIGURATION), 521 .name = "SetConfiguration", 521 522 .callback = on_set_configuration 522 523 }, 523 524 { 524 525 STD_REQ(DIR_IN, REC_DEVICE, USB_DEVREQ_GET_DESCRIPTOR), 526 .name = "GetDescriptor", 525 527 .callback = on_get_descriptor 526 528 }, 527 529 { 528 530 CLASS_REQ(DIR_IN, REC_DEVICE, USB_DEVREQ_GET_DESCRIPTOR), 531 .name = "GetDescriptor", 529 532 .callback = on_get_descriptor 530 533 }, 531 534 { 532 535 CLASS_REQ(DIR_IN, REC_OTHER, USB_HUB_REQUEST_GET_STATUS), 536 .name = "GetPortStatus", 533 537 .callback = req_get_port_status 534 538 }, 535 539 { 536 540 CLASS_REQ(DIR_OUT, REC_DEVICE, USB_HUB_REQUEST_CLEAR_FEATURE), 541 .name = "ClearHubFeature", 537 542 .callback = req_clear_hub_feature 538 543 }, 539 544 { 540 545 CLASS_REQ(DIR_OUT, REC_OTHER, USB_HUB_REQUEST_CLEAR_FEATURE), 546 .name = "ClearPortFeature", 541 547 .callback = req_clear_port_feature 542 548 }, 543 549 { 544 550 CLASS_REQ(DIR_IN, REC_OTHER, USB_HUB_REQUEST_GET_STATE), 551 .name = "GetBusState", 545 552 .callback = req_get_bus_state 546 553 }, 547 554 { 548 555 CLASS_REQ(DIR_IN, REC_DEVICE, USB_HUB_REQUEST_GET_DESCRIPTOR), 556 .name = "GetHubDescriptor", 549 557 .callback = req_get_hub_descriptor 550 558 }, 551 559 { 552 560 CLASS_REQ(DIR_IN, REC_DEVICE, USB_HUB_REQUEST_GET_STATUS), 561 .name = "GetHubStatus", 553 562 .callback = req_get_hub_status 554 563 }, 555 564 { 556 565 CLASS_REQ(DIR_IN, REC_OTHER, USB_HUB_REQUEST_GET_STATUS), 566 .name = "GetPortStatus", 557 567 .callback = req_get_port_status 558 568 }, 559 569 { 560 570 CLASS_REQ(DIR_OUT, REC_DEVICE, USB_HUB_REQUEST_SET_FEATURE), 571 .name = "SetHubFeature", 561 572 .callback = req_set_hub_feature 562 573 }, 563 574 { 564 575 CLASS_REQ(DIR_OUT, REC_OTHER, USB_HUB_REQUEST_SET_FEATURE), 576 .name = "SetPortFeature", 565 577 .callback = req_set_port_feature 566 578 }, -
uspace/lib/usbvirt/include/usbvirt/device.h
r76daaf9f rd5e7668 66 66 uint8_t request_type; 67 67 uint8_t request; 68 const char *name; 68 69 usbvirt_control_request_callback_t callback; 69 70 } usbvirt_control_transfer_handler_t; … … 74 75 | (((recipient) & 31)) 75 76 76 #define USBVIRT_CONTROL_TRANSFER_HANDLER_LAST { 0, 0, NULL }77 #define USBVIRT_CONTROL_TRANSFER_HANDLER_LAST { 0, 0, NULL, NULL } 77 78 78 79 /** Device operations. */ -
uspace/lib/usbvirt/src/ctrlpipe.c
r76daaf9f rd5e7668 76 76 } 77 77 78 #define _GET_BIT(byte, bit) \ 79 (((byte) & (1 << (bit))) ? '1' : '0') 80 #define _GET_BITS(byte) \ 81 _GET_BIT(byte, 7), _GET_BIT(byte, 6), _GET_BIT(byte, 5), \ 82 _GET_BIT(byte, 4), _GET_BIT(byte, 3), _GET_BIT(byte, 2), \ 83 _GET_BIT(byte, 1), _GET_BIT(byte, 0) 84 85 static int find_and_run_handler(usbvirt_device_t *device, 86 usbvirt_control_transfer_handler_t *handlers, 87 usb_device_request_setup_packet_t *setup_packet, 88 uint8_t *data) 89 { 90 int rc = EFORWARD; 91 usbvirt_control_transfer_handler_t *suitable_handler 92 = find_handler(handlers, setup_packet); 93 if (suitable_handler != NULL) { 94 const char *callback_name = "user handler"; 95 if (suitable_handler->name != NULL) { 96 callback_name = suitable_handler->name; 97 } 98 device->lib_debug(device, 1, USBVIRT_DEBUGTAG_CONTROL_PIPE_ZERO, 99 "pipe #0 - calling %s " \ 100 "[%c.%c%c.%c%c%c%c%c, R%d, V%d, I%d, L%d]", 101 callback_name, 102 _GET_BITS(setup_packet->request_type), 103 setup_packet->request, setup_packet->value, 104 setup_packet->index, setup_packet->length); 105 rc = suitable_handler->callback(device, setup_packet, data); 106 } 107 108 return rc; 109 } 110 #undef _GET_BITS 111 #undef _GET_BIT 78 112 79 113 … … 82 116 int control_pipe(usbvirt_device_t *device, usbvirt_control_transfer_t *transfer) 83 117 { 84 device->lib_debug(device, 1, USBVIRT_DEBUGTAG_CONTROL_PIPE_ZERO,118 device->lib_debug(device, 2, USBVIRT_DEBUGTAG_CONTROL_PIPE_ZERO, 85 119 "op on control pipe zero (request_size=%u)", transfer->request_size); 86 120 … … 91 125 usb_device_request_setup_packet_t *request 92 126 = (usb_device_request_setup_packet_t *) transfer->request; 93 printf("Request: %d,%d\n", request->request_type, request->request); 94 127 95 128 /* 96 129 * First, see whether user provided its own callback. … … 98 131 int rc = EFORWARD; 99 132 if (device->ops) { 100 usbvirt_control_transfer_handler_t *user_handler 101 = find_handler(device->ops->control_transfer_handlers, 102 request); 103 if (user_handler != NULL) { 104 rc = user_handler->callback(device, request, 105 transfer->data); 106 } 133 rc = find_and_run_handler(device, 134 device->ops->control_transfer_handlers, 135 request, transfer->data); 107 136 } 108 137 … … 112 141 */ 113 142 if (rc == EFORWARD) { 114 usbvirt_control_transfer_handler_t *lib_handler 115 = find_handler(control_pipe_zero_local_handlers, 116 request); 117 if (lib_handler != NULL) { 118 rc = lib_handler->callback(device, request, 119 transfer->data); 120 } 143 rc = find_and_run_handler(device, 144 control_pipe_zero_local_handlers, 145 request, transfer->data); 121 146 } 122 147 -
uspace/lib/usbvirt/src/stdreq.c
r76daaf9f rd5e7668 184 184 .request_type = MAKE_BM_REQUEST_DEV(USB_DIRECTION_IN), 185 185 .request = USB_DEVREQ_GET_DESCRIPTOR, 186 .name = "GetDescriptor()", 186 187 .callback = handle_get_descriptor 187 188 }, … … 189 190 .request_type = MAKE_BM_REQUEST_DEV(USB_DIRECTION_OUT), 190 191 .request = USB_DEVREQ_SET_ADDRESS, 192 .name = "SetAddress()", 191 193 .callback = handle_set_address 192 194 }, … … 194 196 .request_type = MAKE_BM_REQUEST_DEV(USB_DIRECTION_OUT), 195 197 .request = USB_DEVREQ_SET_CONFIGURATION, 198 .name = "SetConfiguration()", 196 199 .callback = handle_set_configuration 197 200 },
Note:
See TracChangeset
for help on using the changeset viewer.