Changeset f8e8738 in mainline for uspace/lib
- Timestamp:
- 2011-04-07T20:22:40Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- fee6381
- Parents:
- 61257f4 (diff), a82889e (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:
-
- 6 added
- 35 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/Makefile
r61257f4 rf8e8738 77 77 generic/io/io.c \ 78 78 generic/io/printf.c \ 79 generic/io/log.c \ 79 80 generic/io/klog.c \ 80 81 generic/io/snprintf.c \ -
uspace/lib/c/arch/abs32le/_link.ld.in
r61257f4 rf8e8738 11 11 12 12 .text : { 13 *(.text );14 *(.rodata *);13 *(.text .text.*); 14 *(.rodata .rodata.*); 15 15 } :text 16 16 -
uspace/lib/c/arch/amd64/_link.ld.in
r61257f4 rf8e8738 16 16 17 17 .text : { 18 *(.text );19 *(.rodata *);18 *(.text .text.*); 19 *(.rodata .rodata.*); 20 20 } :text 21 21 -
uspace/lib/c/arch/arm32/_link.ld.in
r61257f4 rf8e8738 15 15 16 16 .text : { 17 *(.text );18 *(.rodata *);17 *(.text .text.*); 18 *(.rodata .rodata.*); 19 19 } :text 20 20 -
uspace/lib/c/arch/ia32/_link.ld.in
r61257f4 rf8e8738 16 16 17 17 .text : { 18 *(.text );19 *(.rodata *);18 *(.text .text.*); 19 *(.rodata .rodata.*); 20 20 } :text 21 21 -
uspace/lib/c/arch/ia64/_link.ld.in
r61257f4 rf8e8738 15 15 16 16 .text : { 17 *(.text );18 *(.rodata *);17 *(.text .text.*); 18 *(.rodata .rodata.*); 19 19 } :text 20 20 … … 23 23 .got : { 24 24 _gp = .; 25 *(.got *);25 *(.got .got.*); 26 26 } :data 27 27 -
uspace/lib/c/arch/mips32/_link.ld.in
r61257f4 rf8e8738 15 15 16 16 .text : { 17 *(.text );18 *(.rodata *);17 *(.text .text.*); 18 *(.rodata .rodata.*); 19 19 } :text 20 20 -
uspace/lib/c/arch/ppc32/_link.ld.in
r61257f4 rf8e8738 15 15 16 16 .text : { 17 *(.text );18 *(.rodata *);17 *(.text .text.*); 18 *(.rodata .rodata.*); 19 19 } :text 20 20 -
uspace/lib/c/arch/sparc64/_link.ld.in
r61257f4 rf8e8738 15 15 16 16 .text : { 17 *(.text );18 *(.rodata *);17 *(.text .text.*); 18 *(.rodata .rodata.*); 19 19 } :text 20 20 -
uspace/lib/c/generic/adt/hash_table.c
r61257f4 rf8e8738 54 54 * 55 55 */ 56 inthash_table_create(hash_table_t *h, hash_count_t m, hash_count_t max_keys,56 bool hash_table_create(hash_table_t *h, hash_count_t m, hash_count_t max_keys, 57 57 hash_table_operations_t *op) 58 58 { -
uspace/lib/c/generic/devman.c
r61257f4 rf8e8738 147 147 ret = devman_send_match_id(phone, match_id); 148 148 if (ret != EOK) { 149 printf("Driver failed to send match id, error %d\n",150 ret);151 149 return ret; 152 150 } … … 195 193 } 196 194 197 devman_send_match_ids(phone, match_ids); 198 199 async_wait_for(req, &retval); 200 201 async_serialize_end(); 202 195 int match_ids_rc = devman_send_match_ids(phone, match_ids); 196 197 async_wait_for(req, &retval); 198 199 async_serialize_end(); 200 201 /* Prefer the answer to DEVMAN_ADD_FUNCTION in case of errors. */ 202 if ((match_ids_rc != EOK) && (retval == EOK)) { 203 retval = match_ids_rc; 204 } 205 203 206 if (retval == EOK) 204 207 fun_handle = (int) IPC_GET_ARG1(answer); … … 326 329 } 327 330 331 int devman_device_get_handle_by_class(const char *classname, 332 const char *devname, devman_handle_t *handle, unsigned int flags) 333 { 334 int phone = devman_get_phone(DEVMAN_CLIENT, flags); 335 336 if (phone < 0) 337 return phone; 338 339 async_serialize_start(); 340 341 ipc_call_t answer; 342 aid_t req = async_send_1(phone, DEVMAN_DEVICE_GET_HANDLE_BY_CLASS, 343 flags, &answer); 344 345 sysarg_t retval = async_data_write_start(phone, classname, 346 str_size(classname)); 347 if (retval != EOK) { 348 async_wait_for(req, NULL); 349 async_serialize_end(); 350 return retval; 351 } 352 retval = async_data_write_start(phone, devname, 353 str_size(devname)); 354 if (retval != EOK) { 355 async_wait_for(req, NULL); 356 async_serialize_end(); 357 return retval; 358 } 359 360 async_wait_for(req, &retval); 361 362 async_serialize_end(); 363 364 if (retval != EOK) { 365 if (handle != NULL) 366 *handle = (devman_handle_t) -1; 367 return retval; 368 } 369 370 if (handle != NULL) 371 *handle = (devman_handle_t) IPC_GET_ARG1(answer); 372 373 return retval; 374 } 375 328 376 329 377 /** @} -
uspace/lib/c/generic/net/packet.c
r61257f4 rf8e8738 190 190 } 191 191 } 192 gpm_destroy(&pm_globals.packet_map );192 gpm_destroy(&pm_globals.packet_map, free); 193 193 /* leave locked */ 194 194 } -
uspace/lib/c/generic/net/socket_client.c
r61257f4 rf8e8738 749 749 dyn_fifo_destroy(&socket->received); 750 750 dyn_fifo_destroy(&socket->accepted); 751 sockets_exclude(socket_get_sockets(), socket->socket_id );751 sockets_exclude(socket_get_sockets(), socket->socket_id, free); 752 752 } 753 753 -
uspace/lib/c/generic/vfs/vfs.c
r61257f4 rf8e8738 756 756 { 757 757 struct stat stat; 758 int rc; 759 760 rc = fstat(fildes, &stat); 761 758 759 int rc = fstat(fildes, &stat); 760 if (rc != 0) 761 return rc; 762 762 763 if (!stat.device) 763 764 return -1; -
uspace/lib/c/include/adt/generic_char_map.h
r61257f4 rf8e8738 47 47 #define GENERIC_CHAR_MAP_MAGIC_VALUE 0x12345622 48 48 49 /** Generic destructor function pointer. */ 50 #define DTOR_T(identifier) \ 51 void (*identifier)(const void *) 52 49 53 /** Character string to generic type map declaration. 50 54 * @param[in] name Name of the map. … … 64 68 int name##_add(name##_t *, const uint8_t *, const size_t, type *); \ 65 69 int name##_count(name##_t *); \ 66 void name##_destroy(name##_t * ); \67 void name##_exclude(name##_t *, const uint8_t *, const size_t ); \70 void name##_destroy(name##_t *, DTOR_T()); \ 71 void name##_exclude(name##_t *, const uint8_t *, const size_t, DTOR_T()); \ 68 72 type *name##_find(name##_t *, const uint8_t *, const size_t); \ 69 73 int name##_initialize(name##_t *); \ … … 84 88 type *value) \ 85 89 { \ 86 int rc; \87 90 int index; \ 88 91 if (!name##_is_valid(map)) \ … … 91 94 if (index < 0) \ 92 95 return index; \ 93 rc = char_map_add(&map->names, name, length, index); \ 94 if (rc != EOK) { \ 95 name##_items_exclude_index(&map->values, index); \ 96 return rc; \ 97 } \ 98 return EOK; \ 96 return char_map_add(&map->names, name, length, index); \ 99 97 } \ 100 98 \ … … 105 103 } \ 106 104 \ 107 void name##_destroy(name##_t *map ) \105 void name##_destroy(name##_t *map, DTOR_T(dtor)) \ 108 106 { \ 109 107 if (name##_is_valid(map)) { \ 110 108 char_map_destroy(&map->names); \ 111 name##_items_destroy(&map->values ); \109 name##_items_destroy(&map->values, dtor); \ 112 110 } \ 113 111 } \ 114 112 \ 115 113 void name##_exclude(name##_t *map, const uint8_t *name, \ 116 const size_t length ) \114 const size_t length, DTOR_T(dtor)) \ 117 115 { \ 118 116 if (name##_is_valid(map)) { \ … … 121 119 if (index != CHAR_MAP_NULL) \ 122 120 name##_items_exclude_index(&map->values, \ 123 index ); \121 index, dtor); \ 124 122 } \ 125 123 } \ -
uspace/lib/c/include/adt/generic_field.h
r61257f4 rf8e8738 46 46 #define GENERIC_FIELD_MAGIC_VALUE 0x55667788 47 47 48 /** Generic destructor function pointer. */ 49 #define DTOR_T(identifier) \ 50 void (*identifier)(const void *) 51 48 52 /** Generic type field declaration. 49 53 * … … 63 67 int name##_add(name##_t *, type *); \ 64 68 int name##_count(name##_t *); \ 65 void name##_destroy(name##_t * ); \66 void name##_exclude_index(name##_t *, int ); \69 void name##_destroy(name##_t *, DTOR_T()); \ 70 void name##_exclude_index(name##_t *, int, DTOR_T()); \ 67 71 type **name##_get_field(name##_t *); \ 68 72 type *name##_get_index(name##_t *, int); \ … … 103 107 } \ 104 108 \ 105 void name##_destroy(name##_t *field ) \109 void name##_destroy(name##_t *field, DTOR_T(dtor)) \ 106 110 { \ 107 111 if (name##_is_valid(field)) { \ 108 112 int index; \ 109 113 field->magic = 0; \ 110 for (index = 0; index < field->next; index++) { \ 111 if (field->items[index]) \ 112 free(field->items[index]); \ 114 if (dtor) { \ 115 for (index = 0; index < field->next; index++) { \ 116 if (field->items[index]) \ 117 dtor(field->items[index]); \ 118 } \ 113 119 } \ 114 120 free(field->items); \ … … 116 122 } \ 117 123 \ 118 void name##_exclude_index(name##_t *field, int index ) \124 void name##_exclude_index(name##_t *field, int index, DTOR_T(dtor)) \ 119 125 { \ 120 126 if (name##_is_valid(field) && (index >= 0) && \ 121 127 (index < field->next) && (field->items[index])) { \ 122 free(field->items[index]); \ 128 if (dtor) \ 129 dtor(field->items[index]); \ 123 130 field->items[index] = NULL; \ 124 131 } \ -
uspace/lib/c/include/adt/hash_table.h
r61257f4 rf8e8738 38 38 #include <adt/list.h> 39 39 #include <unistd.h> 40 #include <bool.h> 40 41 41 42 typedef unsigned long hash_count_t; … … 83 84 list_get_instance((item), type, member) 84 85 85 extern inthash_table_create(hash_table_t *, hash_count_t, hash_count_t,86 extern bool hash_table_create(hash_table_t *, hash_count_t, hash_count_t, 86 87 hash_table_operations_t *); 87 88 extern void hash_table_insert(hash_table_t *, unsigned long [], link_t *); -
uspace/lib/c/include/adt/int_map.h
r61257f4 rf8e8738 49 49 #define INT_MAP_ITEM_MAGIC_VALUE 0x55667788 50 50 51 /** Generic destructor function pointer. */ 52 #define DTOR_T(identifier) \ 53 void (*identifier)(const void *) 54 51 55 /** Integer to generic type map declaration. 52 56 * … … 72 76 \ 73 77 int name##_add(name##_t *, int, type *); \ 74 void name##_clear(name##_t * ); \78 void name##_clear(name##_t *, DTOR_T()); \ 75 79 int name##_count(name##_t *); \ 76 void name##_destroy(name##_t * ); \77 void name##_exclude(name##_t *, int ); \78 void name##_exclude_index(name##_t *, int ); \80 void name##_destroy(name##_t *, DTOR_T()); \ 81 void name##_exclude(name##_t *, int, DTOR_T()); \ 82 void name##_exclude_index(name##_t *, int, DTOR_T()); \ 79 83 type *name##_find(name##_t *, int); \ 80 84 int name##_update(name##_t *, int, int); \ … … 82 86 int name##_initialize(name##_t *); \ 83 87 int name##_is_valid(name##_t *); \ 84 void name##_item_destroy(name##_item_t * ); \88 void name##_item_destroy(name##_item_t *, DTOR_T()); \ 85 89 int name##_item_is_valid(name##_item_t *); 86 90 … … 115 119 } \ 116 120 \ 117 void name##_clear(name##_t *map ) \121 void name##_clear(name##_t *map, DTOR_T(dtor)) \ 118 122 { \ 119 123 if (name##_is_valid(map)) { \ … … 122 126 if (name##_item_is_valid(&map->items[index])) { \ 123 127 name##_item_destroy( \ 124 &map->items[index] ); \128 &map->items[index], dtor); \ 125 129 } \ 126 130 } \ … … 135 139 } \ 136 140 \ 137 void name##_destroy(name##_t *map ) \141 void name##_destroy(name##_t *map, DTOR_T(dtor)) \ 138 142 { \ 139 143 if (name##_is_valid(map)) { \ … … 143 147 if (name##_item_is_valid(&map->items[index])) { \ 144 148 name##_item_destroy( \ 145 &map->items[index] ); \149 &map->items[index], dtor); \ 146 150 } \ 147 151 } \ … … 150 154 } \ 151 155 \ 152 void name##_exclude(name##_t *map, int key ) \156 void name##_exclude(name##_t *map, int key, DTOR_T(dtor)) \ 153 157 { \ 154 158 if (name##_is_valid(map)) { \ … … 158 162 (map->items[index].key == key)) { \ 159 163 name##_item_destroy( \ 160 &map->items[index] ); \161 } \ 162 } \ 163 } \ 164 } \ 165 \ 166 void name##_exclude_index(name##_t *map, int index ) \164 &map->items[index], dtor); \ 165 } \ 166 } \ 167 } \ 168 } \ 169 \ 170 void name##_exclude_index(name##_t *map, int index, DTOR_T(dtor)) \ 167 171 { \ 168 172 if (name##_is_valid(map) && (index >= 0) && \ 169 173 (index < map->next) && \ 170 174 name##_item_is_valid(&map->items[index])) { \ 171 name##_item_destroy(&map->items[index] ); \175 name##_item_destroy(&map->items[index], dtor); \ 172 176 } \ 173 177 } \ … … 236 240 } \ 237 241 \ 238 void name##_item_destroy(name##_item_t *item ) \242 void name##_item_destroy(name##_item_t *item, DTOR_T(dtor)) \ 239 243 { \ 240 244 if (name##_item_is_valid(item)) { \ 241 245 item->magic = 0; \ 242 246 if (item->value) { \ 243 free(item->value); \ 247 if (dtor) \ 248 dtor(item->value); \ 244 249 item->value = NULL; \ 245 250 } \ -
uspace/lib/c/include/devman.h
r61257f4 rf8e8738 53 53 extern int devman_device_get_handle(const char *, devman_handle_t *, 54 54 unsigned int); 55 extern int devman_device_get_handle_by_class(const char *, const char *, 56 devman_handle_t *, unsigned int); 55 57 56 58 extern int devman_add_device_to_class(devman_handle_t, const char *); -
uspace/lib/c/include/io/log.h
r61257f4 rf8e8738 1 1 /* 2 * Copyright (c) 2005 Sergey Bondari 2 * Copyright (c) 2011 Vojtech Horky 3 * Copyright (c) 2011 Jiri Svoboda 3 4 * All rights reserved. 4 5 * … … 27 28 */ 28 29 29 /** @addtogroup amd6430 /** @addtogroup libc 30 31 * @{ 31 32 */ 32 /** @file33 */34 33 35 #ifndef KERN_amd64_MEMSTR_H_36 #define KERN_amd64_MEMSTR_H_34 #ifndef LIBC_IO_LOG_H_ 35 #define LIBC_IO_LOG_H_ 37 36 38 # define memcpy(dst, src, cnt) __builtin_memcpy((dst), (src), (cnt))37 #include <stdarg.h> 39 38 40 extern void memsetw(void *, size_t, uint16_t); 41 extern void memsetb(void *, size_t, uint8_t); 39 typedef enum { 40 LVL_FATAL, 41 LVL_ERROR, 42 LVL_WARN, 43 LVL_NOTE, 44 LVL_DEBUG, 45 LVL_DEBUG2, 46 47 /** For checking range of values */ 48 LVL_LIMIT 49 } log_level_t; 50 51 extern int log_init(const char *, log_level_t); 52 extern void log_msg(log_level_t, const char *, ...); 53 extern void log_msgv(log_level_t, const char *, va_list); 42 54 43 55 #endif -
uspace/lib/c/include/ipc/devman.h
r61257f4 rf8e8738 148 148 149 149 typedef enum { 150 DEVMAN_DEVICE_GET_HANDLE = IPC_FIRST_USER_METHOD 150 DEVMAN_DEVICE_GET_HANDLE = IPC_FIRST_USER_METHOD, 151 DEVMAN_DEVICE_GET_HANDLE_BY_CLASS 151 152 } client_to_devman_t; 152 153 -
uspace/lib/drv/Makefile
r61257f4 rf8e8738 36 36 generic/dev_iface.c \ 37 37 generic/remote_char_dev.c \ 38 generic/log.c \ 38 39 generic/remote_hw_res.c \ 39 40 generic/remote_usb.c \ -
uspace/lib/drv/generic/driver.c
r61257f4 rf8e8738 273 273 274 274 res = driver->driver_ops->add_device(dev); 275 if (res == EOK) { 276 printf("%s: new device with handle=%" PRIun " was added.\n", 277 driver->name, dev_handle); 278 } else { 279 printf("%s: failed to add a new device with handle = %" PRIun ".\n", 280 driver->name, dev_handle); 275 if (res != EOK) 281 276 delete_device(dev); 282 }283 277 284 278 async_answer_0(iid, res); -
uspace/lib/drv/include/ddf/log.h
r61257f4 rf8e8738 1 1 /* 2 * Copyright (c) 20 05 Sergey Bondari2 * Copyright (c) 2011 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 /** @addtogroup ia3229 /** @addtogroup libdrv 30 30 * @{ 31 31 */ 32 /** @file33 */34 32 35 #ifndef KERN_ia32_MEMSTR_H_36 #define KERN_ia32_MEMSTR_H_33 #ifndef DDF_LOG_H_ 34 #define DDF_LOG_H_ 37 35 38 # define memcpy(dst, src, cnt) __builtin_memcpy((dst), (src), (cnt))36 #include <io/log.h> 39 37 40 extern void memsetw(void *, size_t, uint16_t);41 extern void memsetb(void *, size_t, uint8_t);38 extern int ddf_log_init(const char *, log_level_t); 39 extern void ddf_msg(log_level_t, const char *, ...); 42 40 43 41 #endif -
uspace/lib/net/tl/socket_core.c
r61257f4 rf8e8738 107 107 socket_release(socket); 108 108 109 socket_cores_exclude(local_sockets, socket->socket_id );109 socket_cores_exclude(local_sockets, socket->socket_id, free); 110 110 } 111 111 … … 230 230 231 231 fail: 232 socket_port_map_destroy(&socket_port->map );232 socket_port_map_destroy(&socket_port->map, free); 233 233 free(socket_port); 234 234 return rc; … … 649 649 if (socket_port->count <= 0) { 650 650 // destroy the map 651 socket_port_map_destroy(&socket_port->map );651 socket_port_map_destroy(&socket_port->map, free); 652 652 // release the port 653 653 socket_ports_exclude(global_sockets, 654 socket->port );654 socket->port, free); 655 655 } else { 656 656 // remove 657 657 socket_port_map_exclude(&socket_port->map, 658 socket->key, socket->key_length );658 socket->key, socket->key_length, free); 659 659 } 660 660 } -
uspace/lib/net/tl/tl_common.c
r61257f4 rf8e8738 182 182 else 183 183 packet_dimensions_exclude(packet_dimensions, 184 DEVICE_INVALID_ID );184 DEVICE_INVALID_ID, free); 185 185 } 186 186 } -
uspace/lib/usb/Makefile
r61257f4 rf8e8738 53 53 src/hidreport.c \ 54 54 src/host/device_keeper.c \ 55 src/host/batch.c 55 src/host/batch.c \ 56 src/host/endpoint.c \ 57 src/host/usb_endpoint_manager.c 56 58 57 59 include $(USPACE_PREFIX)/Makefile.common -
uspace/lib/usb/include/usb/devdrv.h
r61257f4 rf8e8738 47 47 } usb_device_descriptors_t; 48 48 49 /** Wrapper for data related to alternate interface setting. 50 * The pointers will typically point inside configuration descriptor and 51 * thus you shall not deallocate them. 52 */ 53 typedef struct { 54 /** Interface descriptor. */ 55 usb_standard_interface_descriptor_t *interface; 56 /** Pointer to start of descriptor tree bound with this interface. */ 57 uint8_t *nested_descriptors; 58 /** Size of data pointed by nested_descriptors in bytes. */ 59 size_t nested_descriptors_size; 60 } usb_alternate_interface_descriptors_t; 61 62 /** Alternate interface settings. */ 63 typedef struct { 64 /** Array of alternate interfaces descriptions. */ 65 usb_alternate_interface_descriptors_t *alternatives; 66 /** Size of @c alternatives array. */ 67 size_t alternative_count; 68 /** Index of currently selected one. */ 69 size_t current; 70 } usb_alternate_interfaces_t; 71 49 72 /** USB device structure. */ 50 73 typedef struct { … … 56 79 */ 57 80 usb_endpoint_mapping_t *pipes; 81 /** Number of other endpoint pipes. */ 82 size_t pipes_count; 58 83 /** Current interface. 59 84 * Usually, drivers operate on single interface only. … … 61 86 */ 62 87 int interface_no; 88 89 /** Alternative interfaces. 90 * Set to NULL when the driver controls whole device 91 * (i.e. more (or any) interfaces). 92 */ 93 usb_alternate_interfaces_t *alternate_interfaces; 63 94 64 95 /** Some useful descriptors. */ … … 92 123 */ 93 124 const char *name; 94 /** Expected endpoints description, excluding default control endpoint. 125 /** Expected endpoints description. 126 * This description shall exclude default control endpoint (pipe zero) 127 * and must be NULL terminated. 128 * When only control endpoint is expected, you may set NULL directly 129 * without creating one item array containing NULL. 95 130 * 96 * It MUST be of size expected_enpoints_count(excluding default ctrl) + 1 97 * where the last record MUST BE NULL, otherwise catastrophic things may 98 * happen. 131 * When the driver expect single interrupt in endpoint, 132 * the initialization may look like this: 133 \code 134 static usb_endpoint_description_t poll_endpoint_description = { 135 .transfer_type = USB_TRANSFER_INTERRUPT, 136 .direction = USB_DIRECTION_IN, 137 .interface_class = USB_CLASS_HUB, 138 .interface_subclass = 0, 139 .interface_protocol = 0, 140 .flags = 0 141 }; 142 143 static usb_endpoint_description_t *hub_endpoints[] = { 144 &poll_endpoint_description, 145 NULL 146 }; 147 148 static usb_driver_t hub_driver = { 149 .endpoints = hub_endpoints, 150 ... 151 }; 152 \endcode 99 153 */ 100 154 usb_endpoint_description_t **endpoints; … … 105 159 int usb_driver_main(usb_driver_t *); 106 160 161 int usb_device_select_interface(usb_device_t *, uint8_t, 162 usb_endpoint_description_t **); 163 107 164 typedef bool (*usb_polling_callback_t)(usb_device_t *, 108 165 uint8_t *, size_t, void *); 109 166 typedef void (*usb_polling_terminted_callback_t)(usb_device_t *, bool, void *); 110 111 167 112 168 int usb_device_auto_poll(usb_device_t *, size_t, -
uspace/lib/usb/include/usb/host/batch.h
r61257f4 rf8e8738 39 39 #include <usbhc_iface.h> 40 40 #include <usb/usb.h> 41 #include <usb/host/endpoint.h> 41 42 42 43 typedef struct usb_transfer_batch usb_transfer_batch_t; … … 60 61 ddf_fun_t *fun; 61 62 void *arg; 63 endpoint_t *ep; 62 64 void *private_data; 63 65 }; … … 78 80 void *arg, 79 81 ddf_fun_t *fun, 82 endpoint_t *ep, 80 83 void *private_data 81 84 ); -
uspace/lib/usb/include/usb/host/device_keeper.h
r61257f4 rf8e8738 40 40 #ifndef LIBUSB_HOST_DEVICE_KEEPER_H 41 41 #define LIBUSB_HOST_DEVICE_KEEPER_H 42 43 #include <adt/list.h> 42 44 #include <devman.h> 43 45 #include <fibril_synch.h> 44 46 #include <usb/usb.h> 47 #include <usb/host/endpoint.h> 45 48 46 49 /** Number of USB address for array dimensions. */ … … 51 54 usb_speed_t speed; 52 55 bool occupied; 53 bool control_used;54 uint16_t toggle_status[2];56 link_t endpoints; 57 uint16_t control_used; 55 58 devman_handle_t handle; 56 59 }; … … 68 71 void usb_device_keeper_init(usb_device_keeper_t *instance); 69 72 70 void usb_device_keeper_reserve_default_address(usb_device_keeper_t *instance, 71 usb_speed_t speed); 73 void usb_device_keeper_add_ep( 74 usb_device_keeper_t *instance, usb_address_t address, endpoint_t *ep); 75 76 void usb_device_keeper_reserve_default_address( 77 usb_device_keeper_t *instance, usb_speed_t speed); 72 78 73 79 void usb_device_keeper_release_default_address(usb_device_keeper_t *instance); 74 80 75 81 void usb_device_keeper_reset_if_need(usb_device_keeper_t *instance, 76 usb_target_t target, 77 const uint8_t *setup_data); 78 79 int usb_device_keeper_get_toggle(usb_device_keeper_t *instance, 80 usb_target_t target, usb_direction_t direction); 81 82 int usb_device_keeper_set_toggle(usb_device_keeper_t *instance, 83 usb_target_t target, usb_direction_t direction, bool toggle); 82 usb_target_t target, const uint8_t *setup_data); 84 83 85 84 usb_address_t device_keeper_get_free_address(usb_device_keeper_t *instance, … … 99 98 100 99 void usb_device_keeper_use_control(usb_device_keeper_t *instance, 101 usb_ address_t address);100 usb_target_t target); 102 101 103 102 void usb_device_keeper_release_control(usb_device_keeper_t *instance, 104 usb_ address_t address);103 usb_target_t target); 105 104 106 105 #endif -
uspace/lib/usb/include/usb/pipes.h
r61257f4 rf8e8738 107 107 /** Interface number the endpoint must belong to (-1 for any). */ 108 108 int interface_no; 109 /** Alternate interface setting to choose. */ 110 int interface_setting; 109 111 /** Found descriptor fitting the description. */ 110 112 usb_standard_endpoint_descriptor_t *descriptor; -
uspace/lib/usb/src/devdrv.c
r61257f4 rf8e8738 36 36 #include <usb/request.h> 37 37 #include <usb/debug.h> 38 #include <usb/dp.h> 38 39 #include <errno.h> 39 40 #include <str_error.h> … … 86 87 * @return Number of pipes (excluding default control pipe). 87 88 */ 88 static size_t count_other_pipes(usb_ driver_t *drv)89 static size_t count_other_pipes(usb_endpoint_description_t **endpoints) 89 90 { 90 91 size_t count = 0; 91 if ( drv->endpoints == NULL) {92 if (endpoints == NULL) { 92 93 return 0; 93 94 } 94 95 95 while ( drv->endpoints[count] != NULL) {96 while (endpoints[count] != NULL) { 96 97 count++; 97 98 } … … 106 107 * @return Error code. 107 108 */ 108 static int initialize_other_pipes(usb_driver_t *drv, usb_device_t *dev) 109 static int initialize_other_pipes(usb_endpoint_description_t **endpoints, 110 usb_device_t *dev) 109 111 { 110 112 int rc; 111 dev->interface_no = usb_device_get_assigned_interface(dev->ddf_dev); 112 113 size_t pipe_count = count_other_pipes(drv); 113 114 size_t pipe_count = count_other_pipes(endpoints); 115 if (pipe_count == 0) { 116 return EOK; 117 } 118 114 119 dev->pipes = malloc(sizeof(usb_endpoint_mapping_t) * pipe_count); 115 120 if (dev->pipes == NULL) { … … 133 138 } 134 139 135 dev->pipes[i].description = drv->endpoints[i];140 dev->pipes[i].description = endpoints[i]; 136 141 dev->pipes[i].interface_no = dev->interface_no; 142 dev->pipes[i].interface_setting = 0; 137 143 } 138 144 … … 178 184 usb_hc_connection_close(&hc_conn); 179 185 186 dev->pipes_count = pipe_count; 187 180 188 return EOK; 181 189 … … 227 235 } 228 236 237 /* Get our interface. */ 238 dev->interface_no = usb_device_get_assigned_interface(dev->ddf_dev); 239 229 240 /* 230 241 * For further actions, we need open session on default control pipe. … … 251 262 &dev->descriptors.configuration_size); 252 263 if (rc != EOK) { 253 usb_log_error("Failed retrieving configuration descriptor: %s. \n",264 usb_log_error("Failed retrieving configuration descriptor: %s. %s\n", 254 265 dev->ddf_dev->name, str_error(rc)); 255 266 return rc; … … 257 268 258 269 if (driver->endpoints != NULL) { 259 rc = initialize_other_pipes(driver , dev);270 rc = initialize_other_pipes(driver->endpoints, dev); 260 271 } 261 272 … … 271 282 272 283 return rc; 284 } 285 286 /** Count number of alternate settings of a interface. 287 * 288 * @param config_descr Full configuration descriptor. 289 * @param config_descr_size Size of @p config_descr in bytes. 290 * @param interface_no Interface number. 291 * @return Number of alternate interfaces for @p interface_no interface. 292 */ 293 static size_t count_alternate_interfaces(uint8_t *config_descr, 294 size_t config_descr_size, int interface_no) 295 { 296 assert(config_descr != NULL); 297 usb_dp_parser_t dp_parser = { 298 .nesting = usb_dp_standard_descriptor_nesting 299 }; 300 usb_dp_parser_data_t dp_data = { 301 .data = config_descr, 302 .size = config_descr_size, 303 .arg = NULL 304 }; 305 306 size_t alternate_count = 0; 307 308 uint8_t *iface_ptr = usb_dp_get_nested_descriptor(&dp_parser, 309 &dp_data, config_descr); 310 while (iface_ptr != NULL) { 311 usb_standard_interface_descriptor_t *iface 312 = (usb_standard_interface_descriptor_t *) iface_ptr; 313 if (iface->descriptor_type == USB_DESCTYPE_INTERFACE) { 314 if (iface->interface_number == interface_no) { 315 alternate_count++; 316 } 317 } 318 iface_ptr = usb_dp_get_sibling_descriptor(&dp_parser, &dp_data, 319 config_descr, iface_ptr); 320 } 321 322 return alternate_count; 323 } 324 325 /** Initialize structures related to alternate interfaces. 326 * 327 * @param dev Device where alternate settings shall be initialized. 328 * @return Error code. 329 */ 330 static int initialize_alternate_interfaces(usb_device_t *dev) 331 { 332 if (dev->interface_no < 0) { 333 dev->alternate_interfaces = NULL; 334 return EOK; 335 } 336 337 usb_alternate_interfaces_t *alternates 338 = malloc(sizeof(usb_alternate_interfaces_t)); 339 340 if (alternates == NULL) { 341 return ENOMEM; 342 } 343 344 alternates->alternative_count 345 = count_alternate_interfaces(dev->descriptors.configuration, 346 dev->descriptors.configuration_size, dev->interface_no); 347 348 if (alternates->alternative_count == 0) { 349 free(alternates); 350 return ENOENT; 351 } 352 353 alternates->alternatives = malloc(alternates->alternative_count 354 * sizeof(usb_alternate_interface_descriptors_t)); 355 if (alternates->alternatives == NULL) { 356 free(alternates); 357 return ENOMEM; 358 } 359 360 alternates->current = 0; 361 362 usb_dp_parser_t dp_parser = { 363 .nesting = usb_dp_standard_descriptor_nesting 364 }; 365 usb_dp_parser_data_t dp_data = { 366 .data = dev->descriptors.configuration, 367 .size = dev->descriptors.configuration_size, 368 .arg = NULL 369 }; 370 371 usb_alternate_interface_descriptors_t *cur_alt_iface 372 = &alternates->alternatives[0]; 373 374 uint8_t *iface_ptr = usb_dp_get_nested_descriptor(&dp_parser, 375 &dp_data, dp_data.data); 376 while (iface_ptr != NULL) { 377 usb_standard_interface_descriptor_t *iface 378 = (usb_standard_interface_descriptor_t *) iface_ptr; 379 if ((iface->descriptor_type != USB_DESCTYPE_INTERFACE) 380 || (iface->interface_number != dev->interface_no)) { 381 iface_ptr = usb_dp_get_sibling_descriptor(&dp_parser, 382 &dp_data, 383 dp_data.data, iface_ptr); 384 continue; 385 } 386 387 cur_alt_iface->interface = iface; 388 cur_alt_iface->nested_descriptors = iface_ptr + sizeof(*iface); 389 390 /* Find next interface to count size of nested descriptors. */ 391 iface_ptr = usb_dp_get_sibling_descriptor(&dp_parser, &dp_data, 392 dp_data.data, iface_ptr); 393 if (iface_ptr == NULL) { 394 uint8_t *next = dp_data.data + dp_data.size; 395 cur_alt_iface->nested_descriptors_size 396 = next - cur_alt_iface->nested_descriptors; 397 } else { 398 cur_alt_iface->nested_descriptors_size 399 = iface_ptr - cur_alt_iface->nested_descriptors; 400 } 401 402 cur_alt_iface++; 403 } 404 405 dev->alternate_interfaces = alternates; 406 407 return EOK; 273 408 } 274 409 … … 301 436 dev->descriptors.configuration = NULL; 302 437 438 dev->pipes_count = 0; 439 dev->pipes = NULL; 440 303 441 rc = initialize_pipes(dev); 304 442 if (rc != EOK) { … … 307 445 } 308 446 447 (void) initialize_alternate_interfaces(dev); 448 309 449 return driver->ops->add_device(dev); 450 } 451 452 /** Destroy existing pipes of a USB device. 453 * 454 * @param dev Device where to destroy the pipes. 455 * @return Error code. 456 */ 457 static int destroy_current_pipes(usb_device_t *dev) 458 { 459 size_t i; 460 int rc; 461 462 /* TODO: this shall be done under some device mutex. */ 463 464 /* First check that no session is opened. */ 465 for (i = 0; i < dev->pipes_count; i++) { 466 if (usb_pipe_is_session_started(dev->pipes[i].pipe)) { 467 return EBUSY; 468 } 469 } 470 471 /* Prepare connection to HC. */ 472 usb_hc_connection_t hc_conn; 473 rc = usb_hc_connection_initialize_from_device(&hc_conn, dev->ddf_dev); 474 if (rc != EOK) { 475 return rc; 476 } 477 rc = usb_hc_connection_open(&hc_conn); 478 if (rc != EOK) { 479 return rc; 480 } 481 482 /* Destroy the pipes. */ 483 for (i = 0; i < dev->pipes_count; i++) { 484 usb_pipe_unregister(dev->pipes[i].pipe, &hc_conn); 485 free(dev->pipes[i].pipe); 486 } 487 488 usb_hc_connection_close(&hc_conn); 489 490 free(dev->pipes); 491 dev->pipes = NULL; 492 dev->pipes_count = 0; 493 494 return EOK; 495 } 496 497 /** Change interface setting of a device. 498 * This function selects new alternate setting of an interface by issuing 499 * proper USB command to the device and also creates new USB pipes 500 * under @c dev->pipes. 501 * 502 * @warning This function is intended for drivers working at interface level. 503 * For drivers controlling the whole device, you need to change interface 504 * manually using usb_request_set_interface() and creating new pipes 505 * with usb_pipe_initialize_from_configuration(). 506 * 507 * @param dev USB device. 508 * @param alternate_setting Alternate setting to choose. 509 * @param endpoints New endpoint descriptions. 510 * @return Error code. 511 */ 512 int usb_device_select_interface(usb_device_t *dev, uint8_t alternate_setting, 513 usb_endpoint_description_t **endpoints) 514 { 515 if (dev->interface_no < 0) { 516 return EINVAL; 517 } 518 519 int rc; 520 521 /* TODO: more transactional behavior. */ 522 523 /* Destroy existing pipes. */ 524 rc = destroy_current_pipes(dev); 525 if (rc != EOK) { 526 return rc; 527 } 528 529 /* Change the interface itself. */ 530 rc = usb_request_set_interface(&dev->ctrl_pipe, dev->interface_no, 531 alternate_setting); 532 if (rc != EOK) { 533 return rc; 534 } 535 536 /* Create new pipes. */ 537 rc = initialize_other_pipes(endpoints, dev); 538 539 return rc; 310 540 } 311 541 -
uspace/lib/usb/src/host/batch.c
r61257f4 rf8e8738 54 54 void *arg, 55 55 ddf_fun_t *fun, 56 endpoint_t *ep, 56 57 void *private_data 57 58 ) … … 77 78 instance->next_step = NULL; 78 79 instance->error = EOK; 79 80 instance->ep = ep; 80 81 } 81 82 /*----------------------------------------------------------------------------*/ -
uspace/lib/usb/src/host/device_keeper.c
r61257f4 rf8e8738 54 54 for (; i < USB_ADDRESS_COUNT; ++i) { 55 55 instance->devices[i].occupied = false; 56 instance->devices[i].control_used = false;56 instance->devices[i].control_used = 0; 57 57 instance->devices[i].handle = 0; 58 instance->devices[i].toggle_status[0] = 0; 59 instance->devices[i].toggle_status[1] = 0; 60 } 58 list_initialize(&instance->devices[i].endpoints); 59 } 60 } 61 /*----------------------------------------------------------------------------*/ 62 void usb_device_keeper_add_ep( 63 usb_device_keeper_t *instance, usb_address_t address, endpoint_t *ep) 64 { 65 assert(instance); 66 fibril_mutex_lock(&instance->guard); 67 assert(instance->devices[address].occupied); 68 list_append(&ep->same_device_eps, &instance->devices[address].endpoints); 69 fibril_mutex_unlock(&instance->guard); 61 70 } 62 71 /*----------------------------------------------------------------------------*/ … … 66 75 * @param[in] speed Speed of the device requesting default address. 67 76 */ 68 void usb_device_keeper_reserve_default_address( usb_device_keeper_t *instance,69 usb_ speed_t speed)77 void usb_device_keeper_reserve_default_address( 78 usb_device_keeper_t *instance, usb_speed_t speed) 70 79 { 71 80 assert(instance); … … 101 110 * Really ugly one. 102 111 */ 103 void usb_device_keeper_reset_if_need( usb_device_keeper_t *instance,104 usb_ target_t target, const uint8_t *data)112 void usb_device_keeper_reset_if_need( 113 usb_device_keeper_t *instance, usb_target_t target, const uint8_t *data) 105 114 { 106 115 assert(instance); … … 119 128 /* recipient is endpoint, value is zero (ENDPOINT_STALL) */ 120 129 if (((data[0] & 0xf) == 1) && ((data[2] | data[3]) == 0)) { 130 link_t *current = 131 instance->devices[target.address].endpoints.next; 132 while (current != 133 &instance->devices[target.address].endpoints) 134 { 121 135 /* endpoint number is < 16, thus first byte is enough */ 122 instance->devices[target.address].toggle_status[0] &=123 ~(1 <<data[4]);124 instance->devices[target.address].toggle_status[1] &=125 ~(1 << data[4]);136 endpoint_toggle_reset_filtered( 137 current, data[4]); 138 current = current->next; 139 } 126 140 } 127 141 break; … … 131 145 /* target must be device */ 132 146 if ((data[0] & 0xf) == 0) { 133 instance->devices[target.address].toggle_status[0] = 0; 134 instance->devices[target.address].toggle_status[1] = 0; 147 link_t *current = 148 instance->devices[target.address].endpoints.next; 149 while (current != 150 &instance->devices[target.address].endpoints) 151 { 152 endpoint_toggle_reset(current); 153 current = current->next; 154 } 135 155 } 136 156 break; 137 157 } 138 158 fibril_mutex_unlock(&instance->guard); 139 }140 /*----------------------------------------------------------------------------*/141 /** Get current value of endpoint toggle.142 *143 * @param[in] instance Device keeper structure to use.144 * @param[in] target Device and endpoint used.145 * @return Error code146 */147 int usb_device_keeper_get_toggle(usb_device_keeper_t *instance,148 usb_target_t target, usb_direction_t direction)149 {150 assert(instance);151 /* only control pipes are bi-directional and those do not need toggle */152 if (direction == USB_DIRECTION_BOTH)153 return ENOENT;154 int ret;155 fibril_mutex_lock(&instance->guard);156 if (target.endpoint > 15 || target.endpoint < 0157 || target.address >= USB_ADDRESS_COUNT || target.address < 0158 || !instance->devices[target.address].occupied) {159 usb_log_error("Invalid data when asking for toggle value.\n");160 ret = EINVAL;161 } else {162 ret = (instance->devices[target.address].toggle_status[direction]163 >> target.endpoint) & 1;164 }165 fibril_mutex_unlock(&instance->guard);166 return ret;167 }168 /*----------------------------------------------------------------------------*/169 /** Set current value of endpoint toggle.170 *171 * @param[in] instance Device keeper structure to use.172 * @param[in] target Device and endpoint used.173 * @param[in] toggle Toggle value.174 * @return Error code.175 */176 int usb_device_keeper_set_toggle(usb_device_keeper_t *instance,177 usb_target_t target, usb_direction_t direction, bool toggle)178 {179 assert(instance);180 /* only control pipes are bi-directional and those do not need toggle */181 if (direction == USB_DIRECTION_BOTH)182 return ENOENT;183 int ret;184 fibril_mutex_lock(&instance->guard);185 if (target.endpoint > 15 || target.endpoint < 0186 || target.address >= USB_ADDRESS_COUNT || target.address < 0187 || !instance->devices[target.address].occupied) {188 usb_log_error("Invalid data when setting toggle value.\n");189 ret = EINVAL;190 } else {191 if (toggle) {192 instance->devices[target.address].toggle_status[direction]193 |= (1 << target.endpoint);194 } else {195 instance->devices[target.address].toggle_status[direction]196 &= ~(1 << target.endpoint);197 }198 ret = EOK;199 }200 fibril_mutex_unlock(&instance->guard);201 return ret;202 159 } 203 160 /*----------------------------------------------------------------------------*/ … … 208 165 * @return Free address, or error code. 209 166 */ 210 usb_address_t device_keeper_get_free_address( usb_device_keeper_t *instance,211 usb_ speed_t speed)167 usb_address_t device_keeper_get_free_address( 168 usb_device_keeper_t *instance, usb_speed_t speed) 212 169 { 213 170 assert(instance); … … 229 186 instance->devices[new_address].occupied = true; 230 187 instance->devices[new_address].speed = speed; 231 instance->devices[new_address].toggle_status[0] = 0;232 instance->devices[new_address].toggle_status[1] = 0;233 188 instance->last_address = new_address; 234 189 fibril_mutex_unlock(&instance->guard); … … 259 214 * @param[in] address Device address 260 215 */ 261 void usb_device_keeper_release( usb_device_keeper_t *instance,262 usb_ address_t address)216 void usb_device_keeper_release( 217 usb_device_keeper_t *instance, usb_address_t address) 263 218 { 264 219 assert(instance); … … 278 233 * @return USB Address, or error code. 279 234 */ 280 usb_address_t usb_device_keeper_find( usb_device_keeper_t *instance,281 devman_handle_t handle)235 usb_address_t usb_device_keeper_find( 236 usb_device_keeper_t *instance, devman_handle_t handle) 282 237 { 283 238 assert(instance); … … 301 256 * @return USB speed. 302 257 */ 303 usb_speed_t usb_device_keeper_get_speed( usb_device_keeper_t *instance,304 usb_ address_t address)258 usb_speed_t usb_device_keeper_get_speed( 259 usb_device_keeper_t *instance, usb_address_t address) 305 260 { 306 261 assert(instance); … … 310 265 } 311 266 /*----------------------------------------------------------------------------*/ 312 void usb_device_keeper_use_control(usb_device_keeper_t *instance, 313 usb_address_t address) 314 { 315 assert(instance); 316 fibril_mutex_lock(&instance->guard); 317 while (instance->devices[address].control_used) { 267 void usb_device_keeper_use_control( 268 usb_device_keeper_t *instance, usb_target_t target) 269 { 270 assert(instance); 271 const uint16_t ep = 1 << target.endpoint; 272 fibril_mutex_lock(&instance->guard); 273 while (instance->devices[target.address].control_used & ep) { 318 274 fibril_condvar_wait(&instance->change, &instance->guard); 319 275 } 320 instance->devices[address].control_used = true; 321 fibril_mutex_unlock(&instance->guard); 322 } 323 /*----------------------------------------------------------------------------*/ 324 void usb_device_keeper_release_control(usb_device_keeper_t *instance, 325 usb_address_t address) 326 { 327 assert(instance); 328 fibril_mutex_lock(&instance->guard); 329 instance->devices[address].control_used = false; 276 instance->devices[target.address].control_used |= ep; 277 fibril_mutex_unlock(&instance->guard); 278 } 279 /*----------------------------------------------------------------------------*/ 280 void usb_device_keeper_release_control( 281 usb_device_keeper_t *instance, usb_target_t target) 282 { 283 assert(instance); 284 const uint16_t ep = 1 << target.endpoint; 285 fibril_mutex_lock(&instance->guard); 286 assert((instance->devices[target.address].control_used & ep) != 0); 287 instance->devices[target.address].control_used &= ~ep; 330 288 fibril_mutex_unlock(&instance->guard); 331 289 fibril_condvar_signal(&instance->change); -
uspace/lib/usb/src/hub.c
r61257f4 rf8e8738 142 142 DEV_IFACE_ID(USBHC_DEV_IFACE), 143 143 IPC_M_USBHC_RELEASE_ADDRESS, address); 144 } 145 146 static void unregister_control_endpoint_on_default_address( 147 usb_hc_connection_t *connection) 148 { 149 usb_device_connection_t dev_conn; 150 int rc = usb_device_connection_initialize_on_default_address(&dev_conn, 151 connection); 152 if (rc != EOK) { 153 return; 154 } 155 156 usb_pipe_t ctrl_pipe; 157 rc = usb_pipe_initialize_default_control(&ctrl_pipe, &dev_conn); 158 if (rc != EOK) { 159 return; 160 } 161 162 usb_pipe_unregister(&ctrl_pipe, connection); 144 163 } 145 164 … … 235 254 goto leave_release_default_address; 236 255 } 256 257 /* Before sending any traffic, we need to register this 258 * endpoint. 259 */ 260 rc = usb_pipe_register(&ctrl_pipe, 0, connection); 261 if (rc != EOK) { 262 rc = EREFUSED; 263 goto leave_release_default_address; 264 } 237 265 rc = usb_pipe_probe_default_control(&ctrl_pipe); 238 266 if (rc != EOK) { … … 244 272 if (rc != EOK) { 245 273 rc = ENOTCONN; 246 goto leave_ release_default_address;274 goto leave_unregister_endpoint; 247 275 } 248 276 … … 256 284 257 285 /* 286 * Register the control endpoint for the new device. 287 */ 288 rc = usb_pipe_register(&ctrl_pipe, 0, connection); 289 if (rc != EOK) { 290 rc = EREFUSED; 291 goto leave_unregister_endpoint; 292 } 293 294 /* 295 * Release the original endpoint. 296 */ 297 unregister_control_endpoint_on_default_address(connection); 298 299 /* 258 300 * Once the address is changed, we can return the default address. 259 301 */ 260 302 usb_hc_release_default_address(connection); 303 261 304 262 305 /* … … 273 316 } 274 317 318 319 275 320 /* 276 321 * And now inform the host controller about the handle. … … 308 353 usb_pipe_end_session(&ctrl_pipe); 309 354 355 leave_unregister_endpoint: 356 usb_pipe_unregister(&ctrl_pipe, connection); 357 310 358 leave_release_default_address: 311 359 usb_hc_release_default_address(connection); -
uspace/lib/usb/src/pipesinit.c
r61257f4 rf8e8738 121 121 usb_endpoint_mapping_t *mapping, size_t mapping_count, 122 122 usb_endpoint_description_t *found_endpoint, 123 int interface_number )123 int interface_number, int interface_setting) 124 124 { 125 125 while (mapping_count > 0) { … … 127 127 || (mapping->interface_no == interface_number); 128 128 129 bool interface_setting_fits = (mapping->interface_setting < 0) 130 || (mapping->interface_setting == interface_setting); 131 129 132 bool endpoint_descriptions_fits = endpoint_fits_description( 130 133 mapping->description, found_endpoint); 131 134 132 if (interface_number_fits && endpoint_descriptions_fits) { 135 if (interface_number_fits 136 && interface_setting_fits 137 && endpoint_descriptions_fits) { 133 138 return mapping; 134 139 } … … 181 186 */ 182 187 usb_endpoint_mapping_t *ep_mapping = find_endpoint_mapping(mapping, 183 mapping_count, &description, interface->interface_number); 188 mapping_count, &description, 189 interface->interface_number, interface->alternate_setting); 184 190 if (ep_mapping == NULL) { 185 191 return ENOENT; -
uspace/lib/usb/src/request.c
r61257f4 rf8e8738 529 529 return rc; 530 530 } 531 532 531 if (bare_config.descriptor_type != USB_DESCTYPE_CONFIGURATION) { 533 532 return ENOENT;
Note:
See TracChangeset
for help on using the changeset viewer.