Changeset 8c877b2 in mainline for uspace/lib
- Timestamp:
- 2011-03-04T13:05:35Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- d49728c
- Parents:
- dff940f8 (diff), 9a422574 (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/lib
- Files:
-
- 2 added
- 10 edited
- 1 moved
-
c/generic/loader.c (modified) (1 diff)
-
c/generic/vfs/vfs.c (modified) (3 diffs)
-
c/include/ipc/dev_iface.h (modified) (1 diff)
-
drv/Makefile (modified) (1 diff)
-
drv/generic/dev_iface.c (modified) (2 diffs)
-
drv/generic/remote_pci.c (added)
-
drv/include/pci_dev_iface.h (added)
-
drv/include/remote_pci.h (moved) (moved from uspace/drv/usbhid/descparser.h ) (3 diffs)
-
usb/include/usb/classes/hid.h (modified) (2 diffs)
-
usb/include/usb/classes/hidparser.h (modified) (1 diff)
-
usb/include/usb/request.h (modified) (2 diffs)
-
usb/src/hidparser.c (modified) (1 diff)
-
usb/src/request.c (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/loader.c
rdff940f8 r8c877b2 160 160 int rc = async_data_write_start(ldr->phone_id, (void *) pa, pa_len); 161 161 if (rc != EOK) { 162 free(pa); 162 163 async_wait_for(req, NULL); 163 164 return rc; -
uspace/lib/c/generic/vfs/vfs.c
rdff940f8 r8c877b2 69 69 char *ncwd_path; 70 70 char *ncwd_path_nc; 71 size_t total_size; 71 72 72 73 fibril_mutex_lock(&cwd_mutex); … … 77 78 return NULL; 78 79 } 79 ncwd_path_nc = malloc(cwd_size + 1 + size + 1); 80 total_size = cwd_size + 1 + size + 1; 81 ncwd_path_nc = malloc(total_size); 80 82 if (!ncwd_path_nc) { 81 83 fibril_mutex_unlock(&cwd_mutex); 82 84 return NULL; 83 85 } 84 str_cpy(ncwd_path_nc, cwd_size + 1 + size + 1, cwd_path);86 str_cpy(ncwd_path_nc, total_size, cwd_path); 85 87 ncwd_path_nc[cwd_size] = '/'; 86 88 ncwd_path_nc[cwd_size + 1] = '\0'; 87 89 } else { 88 ncwd_path_nc = malloc(size + 1); 90 total_size = size + 1; 91 ncwd_path_nc = malloc(total_size); 89 92 if (!ncwd_path_nc) { 90 93 fibril_mutex_unlock(&cwd_mutex); … … 93 96 ncwd_path_nc[0] = '\0'; 94 97 } 95 str_append(ncwd_path_nc, cwd_size + 1 + size + 1, path);98 str_append(ncwd_path_nc, total_size, path); 96 99 ncwd_path = canonify(ncwd_path_nc, retlen); 97 100 if (!ncwd_path) { -
uspace/lib/c/include/ipc/dev_iface.h
rdff940f8 r8c877b2 38 38 CHAR_DEV_IFACE, 39 39 40 /** Interface provided by any PCI device. */ 41 PCI_DEV_IFACE, 42 40 43 /** Interface provided by any USB device. */ 41 44 USB_DEV_IFACE, -
uspace/lib/drv/Makefile
rdff940f8 r8c877b2 38 38 generic/remote_hw_res.c \ 39 39 generic/remote_usb.c \ 40 generic/remote_pci.c \ 40 41 generic/remote_usbhc.c 41 42 -
uspace/lib/drv/generic/dev_iface.c
rdff940f8 r8c877b2 43 43 #include "remote_usb.h" 44 44 #include "remote_usbhc.h" 45 #include "remote_pci.h" 45 46 46 47 static iface_dipatch_table_t remote_ifaces = { … … 48 49 &remote_hw_res_iface, 49 50 &remote_char_dev_iface, 51 &remote_pci_iface, 50 52 &remote_usb_iface, 51 53 &remote_usbhc_iface -
uspace/lib/drv/include/remote_pci.h
rdff940f8 r8c877b2 1 1 /* 2 * Copyright (c) 201 0 Lubos Slovak2 * Copyright (c) 2011 Jan Vesely 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 /** @addtogroup drvusbhid29 /** @addtogroup libdrv 30 30 * @{ 31 31 */ 32 32 /** @file 33 * Descriptor parser.34 33 */ 35 34 36 #ifndef USBHID_DESCPARSER_H_37 #define USBHID_DESCPARSER_H_35 #ifndef LIBDRV_REMOTE_PCI_H_ 36 #define LIBDRV_REMOTE_PCI_H_ 38 37 39 #include "hid.h" 40 41 int usbkbd_parse_descriptors(const uint8_t *data, size_t size, 42 usb_hid_configuration_t *config); 43 44 void usbkbd_print_config(const usb_hid_configuration_t *config); 38 remote_iface_t remote_pci_iface; 45 39 46 40 #endif … … 49 43 * @} 50 44 */ 45 -
uspace/lib/usb/include/usb/classes/hid.h
rdff940f8 r8c877b2 51 51 } usb_hid_request_t; 52 52 53 typedef enum { 54 USB_HID_REPORT_TYPE_INPUT = 1, 55 USB_HID_REPORT_TYPE_OUTPUT = 2, 56 USB_HID_REPORT_TYPE_FEATURE = 3 57 } usb_hid_report_type_t; 58 59 typedef enum { 60 USB_HID_PROTOCOL_BOOT = 0, 61 USB_HID_PROTOCOL_REPORT = 1 62 } usb_hid_protocol_t; 63 53 64 /** USB/HID subclass constants. */ 54 65 typedef enum { … … 62 73 USB_HID_PROTOCOL_KEYBOARD = 1, 63 74 USB_HID_PROTOCOL_MOUSE = 2 64 } usb_hid_ protocol_t;75 } usb_hid_iface_protocol_t; 65 76 66 77 /** Part of standard USB HID descriptor specifying one class descriptor. -
uspace/lib/usb/include/usb/classes/hidparser.h
rdff940f8 r8c877b2 70 70 } usb_hid_report_in_callbacks_t; 71 71 72 #define USB_HID_BOOT_KEYBOARD_NUM_LOCK 0x01 73 #define USB_HID_BOOT_KEYBOARD_CAPS_LOCK 0x02 74 #define USB_HID_BOOT_KEYBOARD_SCROLL_LOCK 0x04 75 #define USB_HID_BOOT_KEYBOARD_COMPOSE 0x08 76 #define USB_HID_BOOT_KEYBOARD_KANA 0x10 72 73 typedef enum { 74 USB_HID_MOD_LCTRL = 0x01, 75 USB_HID_MOD_LSHIFT = 0x02, 76 USB_HID_MOD_LALT = 0x04, 77 USB_HID_MOD_LGUI = 0x08, 78 USB_HID_MOD_RCTRL = 0x10, 79 USB_HID_MOD_RSHIFT = 0x20, 80 USB_HID_MOD_RALT = 0x40, 81 USB_HID_MOD_RGUI = 0x80, 82 USB_HID_MOD_COUNT = 8 83 } usb_hid_modifiers_t; 84 85 typedef enum { 86 USB_HID_LED_NUM_LOCK = 0x1, 87 USB_HID_LED_CAPS_LOCK = 0x2, 88 USB_HID_LED_SCROLL_LOCK = 0x4, 89 USB_HID_LED_COMPOSE = 0x8, 90 USB_HID_LED_KANA = 0x10, 91 USB_HID_LED_COUNT = 5 92 } usb_hid_led_t; 93 94 static const usb_hid_modifiers_t 95 usb_hid_modifiers_consts[USB_HID_MOD_COUNT] = { 96 USB_HID_MOD_LCTRL, 97 USB_HID_MOD_LSHIFT, 98 USB_HID_MOD_LALT, 99 USB_HID_MOD_LGUI, 100 USB_HID_MOD_RCTRL, 101 USB_HID_MOD_RSHIFT, 102 USB_HID_MOD_RALT, 103 USB_HID_MOD_RGUI 104 }; 105 106 //static const usb_hid_led_t usb_hid_led_consts[USB_HID_LED_COUNT] = { 107 // USB_HID_LED_NUM_LOCK, 108 // USB_HID_LED_CAPS_LOCK, 109 // USB_HID_LED_SCROLL_LOCK, 110 // USB_HID_LED_COMPOSE, 111 // USB_HID_LED_KANA 112 //}; 113 114 //#define USB_HID_BOOT_KEYBOARD_NUM_LOCK 0x01 115 //#define USB_HID_BOOT_KEYBOARD_CAPS_LOCK 0x02 116 //#define USB_HID_BOOT_KEYBOARD_SCROLL_LOCK 0x04 117 //#define USB_HID_BOOT_KEYBOARD_COMPOSE 0x08 118 //#define USB_HID_BOOT_KEYBOARD_KANA 0x10 77 119 78 120 /* -
uspace/lib/usb/include/usb/request.h
rdff940f8 r8c877b2 96 96 int usb_request_set_address(usb_endpoint_pipe_t *, usb_address_t); 97 97 int usb_request_get_descriptor(usb_endpoint_pipe_t *, usb_request_type_t, 98 uint8_t, uint8_t, uint16_t, void *, size_t, size_t *); 98 usb_request_recipient_t, uint8_t, uint8_t, uint16_t, void *, size_t, 99 size_t *); 99 100 int usb_request_get_descriptor_alloc(usb_endpoint_pipe_t *, usb_request_type_t, 100 u int8_t, uint8_t, uint16_t, void **, size_t *);101 usb_request_recipient_t, uint8_t, uint8_t, uint16_t, void **, size_t *); 101 102 int usb_request_get_device_descriptor(usb_endpoint_pipe_t *, 102 103 usb_standard_device_descriptor_t *); … … 105 106 int usb_request_get_full_configuration_descriptor(usb_endpoint_pipe_t *, int, 106 107 void *, size_t, size_t *); 108 int usb_request_get_full_configuration_descriptor_alloc(usb_endpoint_pipe_t *, 109 int, void **, size_t *); 107 110 int usb_request_set_configuration(usb_endpoint_pipe_t *, uint8_t); 108 111 -
uspace/lib/usb/src/hidparser.c
rdff940f8 r8c877b2 144 144 int usb_hid_boot_keyboard_output_report(uint8_t leds, uint8_t *data, size_t size) 145 145 { 146 if (size !=1){146 if (size < 1){ 147 147 return -1; 148 148 } 149 149 150 /* used only first five bits, others are only padding*/ 151 *data = leds; 150 data[0] = leds; 152 151 return EOK; 153 152 } -
uspace/lib/usb/src/request.c
rdff940f8 r8c877b2 36 36 #include <errno.h> 37 37 #include <assert.h> 38 #include <usb/debug.h> 38 39 39 40 #define MAX_DATA_LENGTH ((size_t)(0xFFFF)) … … 209 210 */ 210 211 int usb_request_get_descriptor(usb_endpoint_pipe_t *pipe, 211 usb_request_type_t request_type, 212 usb_request_type_t request_type, usb_request_recipient_t recipient, 212 213 uint8_t descriptor_type, uint8_t descriptor_index, 213 214 uint16_t language, … … 224 225 225 226 return usb_control_request_get(pipe, 226 request_type, USB_REQUEST_RECIPIENT_DEVICE,227 request_type, recipient, 227 228 USB_DEVREQ_GET_DESCRIPTOR, 228 229 wValue, language, … … 242 243 */ 243 244 int usb_request_get_descriptor_alloc(usb_endpoint_pipe_t * pipe, 244 usb_request_type_t request_type, 245 usb_request_type_t request_type, usb_request_recipient_t recipient, 245 246 uint8_t descriptor_type, uint8_t descriptor_index, 246 247 uint16_t language, … … 258 259 uint8_t tmp_buffer[1]; 259 260 size_t bytes_transfered; 260 rc = usb_request_get_descriptor(pipe, request_type, 261 rc = usb_request_get_descriptor(pipe, request_type, recipient, 261 262 descriptor_type, descriptor_index, language, 262 263 &tmp_buffer, 1, &bytes_transfered); … … 283 284 } 284 285 285 rc = usb_request_get_descriptor(pipe, request_type, 286 rc = usb_request_get_descriptor(pipe, request_type, recipient, 286 287 descriptor_type, descriptor_index, language, 287 288 buffer, size, &bytes_transfered); … … 320 321 usb_standard_device_descriptor_t descriptor_tmp; 321 322 int rc = usb_request_get_descriptor(pipe, 322 USB_REQUEST_TYPE_STANDARD, USB_ DESCTYPE_DEVICE,323 0, 0,323 USB_REQUEST_TYPE_STANDARD, USB_REQUEST_RECIPIENT_DEVICE, 324 USB_DESCTYPE_DEVICE, 0, 0, 324 325 &descriptor_tmp, sizeof(descriptor_tmp), 325 326 &actually_transferred); … … 366 367 usb_standard_configuration_descriptor_t descriptor_tmp; 367 368 int rc = usb_request_get_descriptor(pipe, 368 USB_REQUEST_TYPE_STANDARD, USB_ DESCTYPE_CONFIGURATION,369 index, 0,369 USB_REQUEST_TYPE_STANDARD, USB_REQUEST_RECIPIENT_DEVICE, 370 USB_DESCTYPE_CONFIGURATION, index, 0, 370 371 &descriptor_tmp, sizeof(descriptor_tmp), 371 372 &actually_transferred); … … 406 407 407 408 return usb_request_get_descriptor(pipe, 408 USB_REQUEST_TYPE_STANDARD, USB_ DESCTYPE_CONFIGURATION,409 index, 0,409 USB_REQUEST_TYPE_STANDARD, USB_REQUEST_RECIPIENT_DEVICE, 410 USB_DESCTYPE_CONFIGURATION, index, 0, 410 411 descriptor, descriptor_size, actual_size); 412 } 413 414 /** Retrieve full configuration descriptor, allocate space for it. 415 * 416 * The function takes care that full configuration descriptor is returned 417 * (i.e. the function will fail when less data then descriptor.totalLength 418 * is returned). 419 * 420 * @param[in] pipe Control endpoint pipe (session must be already started). 421 * @param[in] index Configuration index. 422 * @param[out] descriptor_ptr Where to store pointer to allocated buffer. 423 * @param[out] descriptor_size Where to store the size of the descriptor. 424 * @return Error code. 425 */ 426 int usb_request_get_full_configuration_descriptor_alloc( 427 usb_endpoint_pipe_t *pipe, int index, 428 void **descriptor_ptr, size_t *descriptor_size) 429 { 430 int rc; 431 432 if (descriptor_ptr == NULL) { 433 return EBADMEM; 434 } 435 436 usb_standard_configuration_descriptor_t bare_config; 437 rc = usb_request_get_bare_configuration_descriptor(pipe, index, 438 &bare_config); 439 if (rc != EOK) { 440 return rc; 441 } 442 443 if (bare_config.descriptor_type != USB_DESCTYPE_CONFIGURATION) { 444 return ENOENT; 445 } 446 if (bare_config.total_length < sizeof(bare_config)) { 447 return ELIMIT; 448 } 449 450 void *buffer = malloc(bare_config.total_length); 451 if (buffer == NULL) { 452 return ENOMEM; 453 } 454 455 size_t transferred = 0; 456 rc = usb_request_get_full_configuration_descriptor(pipe, index, 457 buffer, bare_config.total_length, &transferred); 458 if (rc != EOK) { 459 free(buffer); 460 return rc; 461 } 462 463 if (transferred != bare_config.total_length) { 464 free(buffer); 465 return ELIMIT; 466 } 467 468 /* Everything looks okay, copy the pointers. */ 469 470 *descriptor_ptr = buffer; 471 472 if (descriptor_size != NULL) { 473 *descriptor_size = bare_config.total_length; 474 } 475 476 return EOK; 411 477 } 412 478 … … 452 518 size_t string_descriptor_size = 0; 453 519 rc = usb_request_get_descriptor_alloc(pipe, 454 USB_REQUEST_TYPE_STANDARD, USB_DESCTYPE_STRING, 0, 0, 520 USB_REQUEST_TYPE_STANDARD, USB_REQUEST_RECIPIENT_DEVICE, 521 USB_DESCTYPE_STRING, 0, 0, 455 522 (void **) &string_descriptor, &string_descriptor_size); 456 523 if (rc != EOK) { … … 502 569 * 503 570 * @param[in] pipe Control endpoint pipe (session must be already started). 504 * @param[in] index String index (in native endianess). 571 * @param[in] index String index (in native endianess), 572 * first index has number 1 (index from descriptors can be used directly). 505 573 * @param[in] lang String language (in native endianess). 506 574 * @param[out] string_ptr Where to store allocated string in native encoding. … … 513 581 return EBADMEM; 514 582 } 515 /* Index is actually one byte value. */ 516 if (index > 0xFF) { 583 /* 584 * Index is actually one byte value and zero index is used 585 * to retrieve list of supported languages. 586 */ 587 if ((index < 1) || (index > 0xFF)) { 517 588 return ERANGE; 518 589 } … … 531 602 size_t string_size; 532 603 rc = usb_request_get_descriptor_alloc(pipe, 533 USB_REQUEST_TYPE_STANDARD, USB_ DESCTYPE_STRING,534 index, uint16_host2usb(lang),604 USB_REQUEST_TYPE_STANDARD, USB_REQUEST_RECIPIENT_DEVICE, 605 USB_DESCTYPE_STRING, index, uint16_host2usb(lang), 535 606 (void **) &string, &string_size); 536 607 if (rc != EOK) {
Note:
See TracChangeset
for help on using the changeset viewer.
