Changeset 6986418 in mainline
- Timestamp:
- 2011-01-14T12:20:54Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- b2a6fcfe
- Parents:
- 2b0db98
- Location:
- uspace
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/usbhub/usbhub.c
r2b0db98 r6986418 468 468 target.address = hub_info->usb_device->address; 469 469 target.endpoint = 1;/// \TODO get from endpoint descriptor 470 dprintf(1,"[usb_hub] checking changes for hub at addr %d",471 target.address); 470 /*dprintf(1,"[usb_hub] checking changes for hub at addr %d", 471 target.address);*/ 472 472 473 473 size_t port_count = hub_info->port_count; -
uspace/drv/usbkbd/Makefile
r2b0db98 r6986418 34 34 SOURCES = \ 35 35 main.c \ 36 descparser.c 36 descparser.c \ 37 descdump.c 37 38 38 39 include $(USPACE_PREFIX)/Makefile.common -
uspace/drv/usbkbd/descparser.c
r2b0db98 r6986418 32 32 #include <usb/descriptor.h> 33 33 #include "descparser.h" 34 #include "descdump.h" 34 35 35 36 static void usbkbd_config_free(usb_hid_configuration_t *config) … … 94 95 sizeof(usb_standard_configuration_descriptor_t)); 95 96 pos += sizeof(usb_standard_configuration_descriptor_t); 97 98 printf("Parsed configuration descriptor: \n"); 99 dump_standard_configuration_descriptor(0, &config->config_descriptor); 96 100 97 101 int ret = EOK; … … 102 106 *(pos + 1)); 103 107 return EINVAL; 104 } 108 } 105 109 106 110 // prepare place for interface descriptors … … 112 116 // the respective structures 113 117 int ep_i = -1; 114 int hid_i = -1;118 //int hid_i = -1; 115 119 116 120 usb_hid_iface_t *actual_iface = NULL; … … 134 138 memcpy(&actual_iface->iface_desc, pos, desc_size); 135 139 pos += desc_size; 140 141 printf("Parsed interface descriptor: \n"); 142 dump_standard_interface_descriptor(&actual_iface->iface_desc); 136 143 137 144 // allocate space for endpoint descriptors … … 170 177 memcpy(&actual_iface->endpoints[ep_i], pos, desc_size); 171 178 pos += desc_size; 179 180 printf("Parsed endpoint descriptor: \n"); 181 dump_standard_endpoint_descriptor(&actual_iface->endpoints[ep_i]); 172 182 ++ep_i; 173 183 … … 194 204 goto end; 195 205 } 206 207 printf("Parsed HID descriptor header: \n"); 208 dump_standard_hid_descriptor_header(&actual_iface->hid_desc); 196 209 197 210 // allocate space for all class-specific descriptor info … … 206 219 207 220 // allocate space for all class-specific descriptors 208 actual_iface->class_descs = (uint8_t **)calloc(221 /*actual_iface->class_descs = (uint8_t **)calloc( 209 222 actual_iface->hid_desc.class_desc_count, 210 223 sizeof(uint8_t *)); … … 212 225 ret = ENOMEM; 213 226 goto end; 214 } 227 }*/ 215 228 216 229 // copy all class-specific descriptor info 217 230 // TODO: endianness 231 /* 218 232 memcpy(actual_iface->class_desc_info, pos, 219 233 actual_iface->hid_desc.class_desc_count … … 221 235 pos += actual_iface->hid_desc.class_desc_count 222 236 * sizeof(usb_standard_hid_class_descriptor_info_t); 223 224 size_t tmp = (size_t)(pos - data); 237 238 printf("Parsed HID descriptor info:\n"); 239 dump_standard_hid_class_descriptor_info( 240 actual_iface->class_desc_info); 241 */ 242 243 /*size_t tmp = (size_t)(pos - data); 225 244 printf("Parser position: %d, remaining: %d\n", 226 pos - data, size - tmp); 227 228 /* 229 * TODO: this is not good, only 7 bytes remaining, 230 * something is wrong! 231 */ 232 233 hid_i = 0; 245 pos - data, size - tmp);*/ 246 247 //hid_i = 0; 234 248 235 249 break; 236 case USB_DESCTYPE_HID_REPORT:250 /* case USB_DESCTYPE_HID_REPORT: 237 251 case USB_DESCTYPE_HID_PHYSICAL: { 238 252 // check if the type matches … … 262 276 memcpy(actual_iface->class_descs[hid_i], pos, length); 263 277 pos += length; 278 279 printf("Parsed class-specific descriptor:\n"); 280 dump_hid_class_descriptor(hid_i, desc_type, 281 actual_iface->class_descs[hid_i], length); 282 264 283 ++hid_i; 265 284 266 break; } 285 break; }*/ 267 286 default: 268 287 fprintf(stderr, "Got descriptor of unknown type: %u.\n", … … 280 299 281 300 return ret; 282 }283 284 /*----------------------------------------------------------------------------*/285 286 #define BYTES_PER_LINE 12287 288 static void dump_buffer(const char *msg, const uint8_t *buffer, size_t length)289 {290 printf("%s\n", msg);291 292 size_t i;293 for (i = 0; i < length; i++) {294 printf(" 0x%02X", buffer[i]);295 if (((i > 0) && (((i+1) % BYTES_PER_LINE) == 0))296 || (i + 1 == length)) {297 printf("\n");298 }299 }300 }301 302 /*----------------------------------------------------------------------------*/303 304 #define INDENT " "305 306 static void dump_standard_configuration_descriptor(307 int index, const usb_standard_configuration_descriptor_t *d)308 {309 bool self_powered = d->attributes & 64;310 bool remote_wakeup = d->attributes & 32;311 312 printf("Standard configuration descriptor #%d\n", index);313 printf(INDENT "bLength = %d\n", d->length);314 printf(INDENT "bDescriptorType = 0x%02x\n", d->descriptor_type);315 printf(INDENT "wTotalLength = %d\n", d->total_length);316 printf(INDENT "bNumInterfaces = %d\n", d->interface_count);317 printf(INDENT "bConfigurationValue = %d\n", d->configuration_number);318 printf(INDENT "iConfiguration = %d\n", d->str_configuration);319 printf(INDENT "bmAttributes = %d [%s%s%s]\n", d->attributes,320 self_powered ? "self-powered" : "",321 (self_powered & remote_wakeup) ? ", " : "",322 remote_wakeup ? "remote-wakeup" : "");323 printf(INDENT "MaxPower = %d (%dmA)\n", d->max_power,324 2 * d->max_power);325 // printf(INDENT " = %d\n", d->);326 }327 328 static void dump_standard_interface_descriptor(329 const usb_standard_interface_descriptor_t *d)330 {331 printf("Standard interface descriptor\n");332 printf(INDENT "bLength = %d\n", d->length);333 printf(INDENT "bDescriptorType = 0x%02x\n", d->descriptor_type);334 printf(INDENT "bInterfaceNumber = %d\n", d->interface_number);335 printf(INDENT "bAlternateSetting = %d\n", d->alternate_setting);336 printf(INDENT "bNumEndpoints = %d\n", d->endpoint_count);337 printf(INDENT "bInterfaceClass = %d\n", d->interface_class);338 printf(INDENT "bInterfaceSubClass = %d\n", d->interface_subclass);339 printf(INDENT "bInterfaceProtocol = %d\n", d->interface_protocol);340 printf(INDENT "iInterface = %d", d->str_interface);341 }342 343 static void dump_standard_endpoint_descriptor(344 const usb_standard_endpoint_descriptor_t *d)345 {346 const char *transfer_type;347 switch (d->attributes & 3) {348 case USB_TRANSFER_CONTROL:349 transfer_type = "control";350 break;351 case USB_TRANSFER_ISOCHRONOUS:352 transfer_type = "isochronous";353 break;354 case USB_TRANSFER_BULK:355 transfer_type = "bulk";356 break;357 case USB_TRANSFER_INTERRUPT:358 transfer_type = "interrupt";359 break;360 }361 362 printf("Standard endpoint descriptor\n");363 printf(INDENT "bLength = %d\n", d->length);364 printf(INDENT "bDescriptorType = 0x%02x\n", d->descriptor_type);365 printf(INDENT "bmAttributes = %d [%s]\n", d->attributes, transfer_type);366 printf(INDENT "wMaxPacketSize = %d\n", d->max_packet_size);367 printf(INDENT "bInterval = %d\n", d->poll_interval);368 }369 370 static void dump_standard_hid_descriptor_header(371 const usb_standard_hid_descriptor_t *d)372 {373 printf("Standard HID descriptor\n");374 printf(INDENT "bLength = %d\n", d->length);375 printf(INDENT "bDescriptorType = 0x%02x\n", d->descriptor_type);376 printf(INDENT "bcdHID = %d\n", d->spec_release);377 printf(INDENT "bCountryCode = %d\n", d->country_code);378 printf(INDENT "bNumDescriptors = %d\n", d->class_desc_count);379 }380 381 static void dump_standard_hid_class_descriptor_info(382 const usb_standard_hid_class_descriptor_info_t *d)383 {384 printf(INDENT "bDescriptorType = %d\n", d->type);385 printf(INDENT "wDescriptorLength = %d\n", d->length);386 }387 388 static void dump_hid_class_descriptor(int index, uint8_t type,389 const uint8_t *d, size_t size )390 {391 printf("Class-specific descriptor #%d (type: %u)\n", index, type);392 assert(d != NULL);393 dump_buffer("", d, size);394 301 } 395 302 -
uspace/drv/usbkbd/descparser.h
r2b0db98 r6986418 26 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 27 */ 28 #ifndef USBHID_DESCPARSER_H_ 29 #define USBHID_DESCPARSER_H_ 30 28 31 #include <usb/classes/hid.h> 29 32 … … 32 35 33 36 void usbkbd_print_config(const usb_hid_configuration_t *config); 37 38 #endif -
uspace/drv/usbkbd/main.c
r2b0db98 r6986418 107 107 * Kbd functions 108 108 */ 109 static int usbkbd_get_report_descriptor(usb_hid_dev_kbd_t *kbd_dev) 110 { 111 // iterate over all configurations and interfaces 112 // TODO: more configurations!! 113 unsigned i; 114 for (i = 0; i < kbd_dev->conf->config_descriptor.interface_count; ++i) { 115 uint8_t type = 116 kbd_dev->conf->interfaces[i].hid_desc.report_desc_info.type; 117 // TODO: endianness 118 uint16_t length = 119 kbd_dev->conf->interfaces[i].hid_desc.report_desc_info.length; 120 121 // allocate space for the report descriptor 122 kbd_dev->conf->interfaces[i].report_desc = (uint8_t *)malloc(length); 123 // get the descriptor from the device 124 125 } 126 } 127 109 128 static int usbkbd_process_descriptors(usb_hid_dev_kbd_t *kbd_dev) 110 129 { … … 147 166 rc = usbkbd_parse_descriptors(descriptors, transferred, kbd_dev->conf); 148 167 free(descriptors); 149 150 //usbkbd_print_config(kbd_dev->conf); 168 169 // get and report descriptors 170 rc = usbkbd_get_report_descriptor(kbd_dev); 171 172 usbkbd_print_config(kbd_dev->conf); 151 173 152 174 return rc; … … 223 245 static void usbkbd_poll_keyboard(usb_hid_dev_kbd_t *kbd_dev) 224 246 { 247 return; 248 225 249 int rc; 226 250 usb_handle_t handle; -
uspace/lib/usb/include/usb/classes/hid.h
r2b0db98 r6986418 93 93 /** Total number of class-specific (i.e. Report and Physical) 94 94 * descriptors. 95 * 96 * @note There is always only one Report descriptor. 95 97 */ 96 98 uint8_t class_desc_count; 97 // /** First mandatory class descriptorinfo. */98 // usb_standard_hid_descriptor_class_item_t class_descriptor;99 /** First mandatory class descriptor (Report) info. */ 100 usb_standard_hid_descriptor_class_item_t report_desc_info; 99 101 } __attribute__ ((packed)) usb_standard_hid_descriptor_t; 100 102 … … 106 108 usb_standard_endpoint_descriptor_t *endpoints; 107 109 usb_standard_hid_descriptor_t hid_desc; 108 usb_standard_hid_class_descriptor_info_t *class_desc_info; 109 uint8_t **class_descs; 110 uint8_t *report_desc; 111 //usb_standard_hid_class_descriptor_info_t *class_desc_info; 112 //uint8_t **class_descs; 110 113 } usb_hid_iface_t; 111 114 … … 131 134 } usb_hid_dev_kbd_t; 132 135 136 // TODO: more configurations! 137 133 138 #endif 134 139 /**
Note:
See TracChangeset
for help on using the changeset viewer.