Changes in / [f401312:6610565b] in mainline
- Location:
- uspace
- Files:
-
- 4 deleted
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/virtusbkbd/virtusbkbd.c
rf401312 r6610565b 271 271 printf("%s: Simulating keyboard events...\n", NAME); 272 272 fibril_sleep(10); 273 //while (1) {273 while (1) { 274 274 kb_process_events(&status, keyboard_events, keyboard_events_count, 275 275 on_keyboard_change); 276 //}276 } 277 277 278 278 printf("%s: Terminating...\n", NAME); -
uspace/drv/usbhub/usbhub.c
rf401312 r6610565b 462 462 target.address = hub_info->usb_device->address; 463 463 target.endpoint = 1;/// \TODO get from endpoint descriptor 464 /*dprintf(1,"[usb_hub] checking changes for hub at addr %d",465 target.address); */464 dprintf(1,"[usb_hub] checking changes for hub at addr %d", 465 target.address); 466 466 467 467 size_t port_count = hub_info->port_count; -
uspace/drv/usbkbd/Makefile
rf401312 r6610565b 33 33 34 34 SOURCES = \ 35 main.c \ 36 descparser.c \ 37 descdump.c 35 main.c 38 36 39 37 include $(USPACE_PREFIX)/Makefile.common -
uspace/drv/usbkbd/main.c
rf401312 r6610565b 38 38 #include <usb/devreq.h> 39 39 #include <usb/descriptor.h> 40 #include "descparser.h"41 40 42 41 #define BUFFER_SIZE 32 … … 92 91 void *arg) 93 92 { 94 printf("Got keys: "); 95 unsigned i; 96 for (i = 0; i < count; ++i) { 97 printf("%d ", key_codes[i]); 98 } 99 printf("\n"); 93 100 94 } 101 95 … … 103 97 * Kbd functions 104 98 */ 105 static int usbkbd_get_report_descriptor(usb_hid_dev_kbd_t *kbd_dev) 106 { 107 // iterate over all configurations and interfaces 108 // TODO: more configurations!! 109 unsigned i; 110 for (i = 0; i < kbd_dev->conf->config_descriptor.interface_count; ++i) { 111 uint8_t type = 112 kbd_dev->conf->interfaces[i].hid_desc.report_desc_info.type; 113 // TODO: endianness 114 uint16_t length = 115 kbd_dev->conf->interfaces[i].hid_desc.report_desc_info.length; 116 117 // allocate space for the report descriptor 118 kbd_dev->conf->interfaces[i].report_desc = (uint8_t *)malloc(length); 119 // get the descriptor from the device 120 121 } 122 } 123 124 static int usbkbd_process_descriptors(usb_hid_dev_kbd_t *kbd_dev) 125 { 126 // get the first configuration descriptor (TODO: parse also other!) 99 static int usbkbd_parse_descriptors(usb_hid_dev_kbd_t *kbd_dev, 100 const uint8_t *data, size_t size) 101 { 102 // const uint8_t *pos = data; 103 104 // // get the configuration descriptor (should be first) 105 // if (*pos != sizeof(usb_standard_configuration_descriptor_t) 106 // || *(pos + 1) != USB_DESCTYPE_CONFIGURATION) { 107 // fprintf(stderr, "Wrong format of configuration descriptor"); 108 // return EINVAL; 109 // } 110 111 // usb_standard_configuration_descriptor_t config_descriptor; 112 // memcpy(&config_descriptor, pos, 113 // sizeof(usb_standard_configuration_descriptor_t)); 114 // pos += sizeof(usb_standard_configuration_descriptor_t); 115 116 // // parse other descriptors 117 // while (pos - data < size) { 118 // //uint8_t desc_size = *pos; 119 // uint8_t desc_type = *(pos + 1); 120 // switch (desc_type) { 121 // case USB_DESCTYPE_INTERFACE: 122 // break; 123 // case USB_DESCTYPE_ENDPOINT: 124 // break; 125 // case USB_DESCTYPE_HID: 126 // break; 127 // case USB_DESCTYPE_HID_REPORT: 128 // break; 129 // case USB_DESCTYPE_HID_PHYSICAL: 130 // break; 131 // } 132 // } 133 134 return EOK; 135 } 136 137 static int usbkbd_get_descriptors(usb_hid_dev_kbd_t *kbd_dev) 138 { 139 // get the first configuration descriptor (TODO: or some other??) 127 140 usb_standard_configuration_descriptor_t config_desc; 128 141 … … 153 166 } 154 167 155 kbd_dev->conf = (usb_hid_configuration_t *)calloc(1, 156 sizeof(usb_hid_configuration_t)); 157 if (kbd_dev->conf == NULL) { 158 free(descriptors); 159 return ENOMEM; 160 } 161 162 rc = usbkbd_parse_descriptors(descriptors, transferred, kbd_dev->conf); 168 rc = usbkbd_parse_descriptors(kbd_dev, descriptors, transferred); 163 169 free(descriptors); 164 165 // get and report descriptors166 rc = usbkbd_get_report_descriptor(kbd_dev);167 168 usbkbd_print_config(kbd_dev->conf);169 170 170 171 return rc; … … 173 174 static usb_hid_dev_kbd_t *usbkbd_init_device(device_t *dev) 174 175 { 175 usb_hid_dev_kbd_t *kbd_dev = (usb_hid_dev_kbd_t *) calloc(1,176 176 usb_hid_dev_kbd_t *kbd_dev = (usb_hid_dev_kbd_t *)malloc( 177 sizeof(usb_hid_dev_kbd_t)); 177 178 178 179 if (kbd_dev == NULL) { … … 207 208 */ 208 209 209 // TODO: get descriptors, parse descriptors and save endpoints 210 usbkbd_process_descriptors(kbd_dev); 210 // TODO: get descriptors 211 usbkbd_get_descriptors(kbd_dev); 212 // TODO: parse descriptors and save endpoints 211 213 212 214 return kbd_dev; … … 232 234 static void usbkbd_poll_keyboard(usb_hid_dev_kbd_t *kbd_dev) 233 235 { 234 return;235 236 236 int rc; 237 237 usb_handle_t handle; -
uspace/drv/vhc/hcd.c
rf401312 r6610565b 116 116 sleep(5); 117 117 118 usb_dprintf_enable(NAME, -1);118 usb_dprintf_enable(NAME, 0); 119 119 120 120 printf(NAME ": virtual USB host controller driver.\n"); -
uspace/lib/usb/include/usb/classes/hid.h
rf401312 r6610565b 39 39 #include <driver.h> 40 40 #include <usb/classes/hidparser.h> 41 #include <usb/descriptor.h>42 41 43 42 /** USB/HID device requests. */ … … 64 63 */ 65 64 typedef struct { 66 /** Type of class -specificdescriptor (Report or Physical). */67 uint8_t type;68 /** Length of class -specific descriptor in bytes. */69 uint16_t length;70 } __attribute__ ((packed)) usb_standard_hid_ class_descriptor_info_t;65 /** Type of class descriptor (Report or Physical). */ 66 uint8_t class_descriptor_type; 67 /** Length of class descriptor. */ 68 uint16_t class_descriptor_length; 69 } __attribute__ ((packed)) usb_standard_hid_descriptor_class_item_t; 71 70 72 71 /** Standard USB HID descriptor. … … 74 73 * (See HID Specification, p.22) 75 74 * 76 * It is actually only the "header" of the descriptor, it does not contain 77 * the last two mandatory fields (type and length of the first class-specific 78 * descriptor). 75 * It is actually only the "header" of the descriptor, as it may have arbitrary 76 * length if more than one class descritor is provided. 79 77 */ 80 78 typedef struct { 81 /** Total size of this descriptor in bytes. 82 * 83 * This includes all class-specific descriptor info - type + length 84 * for each descriptor. 85 */ 79 /** Size of this descriptor in bytes. */ 86 80 uint8_t length; 87 81 /** Descriptor type (USB_DESCTYPE_HID). */ … … 91 85 /** Country code of localized hardware. */ 92 86 uint8_t country_code; 93 /** Total number of class-specific (i.e. Report and Physical) 94 * descriptors. 95 * 96 * @note There is always only one Report descriptor. 97 */ 98 uint8_t class_desc_count; 99 /** First mandatory class descriptor (Report) info. */ 100 usb_standard_hid_descriptor_class_item_t report_desc_info; 87 /** Total number of class (i.e. Report and Physical) descriptors. */ 88 uint8_t class_count; 89 /** First mandatory class descriptor info. */ 90 usb_standard_hid_descriptor_class_item_t class_descriptor; 101 91 } __attribute__ ((packed)) usb_standard_hid_descriptor_t; 102 92 103 /**104 *105 */106 typedef struct {107 usb_standard_interface_descriptor_t iface_desc;108 usb_standard_endpoint_descriptor_t *endpoints;109 usb_standard_hid_descriptor_t hid_desc;110 uint8_t *report_desc;111 //usb_standard_hid_class_descriptor_info_t *class_desc_info;112 //uint8_t **class_descs;113 } usb_hid_iface_t;114 115 /**116 *117 */118 typedef struct {119 usb_standard_configuration_descriptor_t config_descriptor;120 usb_hid_iface_t *interfaces;121 } usb_hid_configuration_t;122 93 123 94 /** … … 128 99 typedef struct { 129 100 device_t *device; 130 usb_hid_configuration_t *conf;131 101 usb_address_t address; 132 102 usb_endpoint_t poll_endpoint; … … 134 104 } usb_hid_dev_kbd_t; 135 105 136 // TODO: more configurations!137 138 106 #endif 139 107 /** -
uspace/srv/devman/main.c
rf401312 r6610565b 479 479 } 480 480 481 //printf(NAME ": devman_forward: forward connection to device %s to "482 //"driver %s.\n", dev->pathname, driver->name);481 printf(NAME ": devman_forward: forward connection to device %s to " 482 "driver %s.\n", dev->pathname, driver->name); 483 483 ipc_forward_fast(iid, driver->phone, method, dev->handle, 0, IPC_FF_NONE); 484 484 }
Note:
See TracChangeset
for help on using the changeset viewer.