Changes in / [5542b83:969585f] in mainline
- Location:
- uspace
- Files:
-
- 2 deleted
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/uhci-hcd/hc.c
r5542b83 r969585f 239 239 usb_log_debug("Initialized device manager.\n"); 240 240 241 ret = bandwidth_init(&instance->bandwidth, BANDWIDTH_AVAILABLE_USB11,242 bandwidth_count_usb11);243 assert(ret == true);244 245 241 return EOK; 246 242 #undef CHECK_RET_DEST_CMDS_RETURN … … 329 325 if (!usb_is_allowed( 330 326 low_speed, batch->transfer_type, batch->max_packet_size)) { 331 usb_log_error("Invalid USB transfer specified %s %d %zu.\n", 332 usb_str_speed(batch->speed), batch->transfer_type, 327 usb_log_warning( 328 "Invalid USB transfer specified %s SPEED %d %zu.\n", 329 low_speed ? "LOW" : "FULL" , batch->transfer_type, 333 330 batch->max_packet_size); 334 331 return ENOTSUP; 335 332 } 336 /* Check available bandwidth */ 337 if (batch->transfer_type == USB_TRANSFER_INTERRUPT || 338 batch->transfer_type == USB_TRANSFER_ISOCHRONOUS) { 339 int ret = 340 bandwidth_use(&instance->bandwidth, batch->target.address, 341 batch->target.endpoint, batch->direction); 342 if (ret != EOK) { 343 usb_log_warning("Failed(%d) to use reserved bw: %s.\n", 344 ret, str_error(ret)); 345 } 346 } 333 /* TODO: check available bandwidth here */ 347 334 348 335 transfer_list_t *list = … … 351 338 if (batch->transfer_type == USB_TRANSFER_CONTROL) { 352 339 usb_device_keeper_use_control( 353 &instance->manager, batch->target );340 &instance->manager, batch->target.address); 354 341 } 355 342 transfer_list_add_batch(list, batch); … … 371 358 { 372 359 assert(instance); 373 // status |= 1; //Uncomment to work around qemu hang374 360 /* TODO: Resume interrupts are not supported */ 375 361 /* Lower 2 bits are transaction error and transaction complete */ … … 390 376 usb_transfer_batch_t *batch = 391 377 list_get_instance(item, usb_transfer_batch_t, link); 392 switch (batch->transfer_type) 393 { 394 case USB_TRANSFER_CONTROL: 378 if (batch->transfer_type == USB_TRANSFER_CONTROL) { 395 379 usb_device_keeper_release_control( 396 &instance->manager, batch->target); 397 break; 398 case USB_TRANSFER_INTERRUPT: 399 case USB_TRANSFER_ISOCHRONOUS: { 400 int ret = bandwidth_free(&instance->bandwidth, 401 batch->target.address, 402 batch->target.endpoint, 403 batch->direction); 404 if (ret != EOK) 405 usb_log_warning("Failed(%d) to free " 406 "reserved bw: %s.\n", ret, 407 str_error(ret)); 408 } 409 default: 410 break; 380 &instance->manager, batch->target.address); 411 381 } 412 382 batch->next_step(batch); -
uspace/drv/uhci-hcd/hc.h
r5542b83 r969585f 43 43 #include <usbhc_iface.h> 44 44 #include <usb/host/device_keeper.h> 45 #include <usb/host/bandwidth.h>46 45 47 46 #include "batch.h" … … 85 84 typedef struct hc { 86 85 usb_device_keeper_t manager; 87 bandwidth_t bandwidth;88 86 89 87 regs_t *registers; -
uspace/drv/uhci-hcd/iface.c
r5542b83 r969585f 128 128 } 129 129 /*----------------------------------------------------------------------------*/ 130 static int register_endpoint(131 ddf_fun_t *fun, usb_address_t address, usb_endpoint_t endpoint,132 usb_transfer_type_t transfer_type, usb_direction_t direction,133 size_t max_packet_size, unsigned int interval)134 {135 hc_t *hc = fun_to_hc(fun);136 assert(hc);137 const usb_speed_t speed =138 usb_device_keeper_get_speed(&hc->manager, address);139 size_t size = max_packet_size;140 141 usb_log_debug("Register endpoint %d:%d %s %s(%d) %zu(%zu) %u.\n",142 address, endpoint, usb_str_transfer_type(transfer_type),143 usb_str_speed(speed), direction, size, max_packet_size, interval);144 return bandwidth_reserve(&hc->bandwidth, address, endpoint, direction,145 speed, transfer_type, max_packet_size, size, interval);146 }147 /*----------------------------------------------------------------------------*/148 static int unregister_endpoint(149 ddf_fun_t *fun, usb_address_t address,150 usb_endpoint_t endpoint, usb_direction_t direction)151 {152 hc_t *hc = fun_to_hc(fun);153 assert(hc);154 usb_log_debug("Unregister endpoint %d:%d %d.\n",155 address, endpoint, direction);156 return bandwidth_release(&hc->bandwidth, address, endpoint, direction);157 }158 /*----------------------------------------------------------------------------*/159 130 /** Interrupt out transaction interface function 160 131 * … … 394 365 .release_address = release_address, 395 366 396 .register_endpoint = register_endpoint,397 .unregister_endpoint = unregister_endpoint,398 399 367 .interrupt_out = interrupt_out, 400 368 .interrupt_in = interrupt_in, -
uspace/lib/c/generic/adt/hash_table.c
r5542b83 r969585f 54 54 * 55 55 */ 56 boolhash_table_create(hash_table_t *h, hash_count_t m, hash_count_t max_keys,56 int 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/include/adt/hash_table.h
r5542b83 r969585f 38 38 #include <adt/list.h> 39 39 #include <unistd.h> 40 #include <bool.h>41 40 42 41 typedef unsigned long hash_count_t; … … 84 83 list_get_instance((item), type, member) 85 84 86 extern boolhash_table_create(hash_table_t *, hash_count_t, hash_count_t,85 extern int hash_table_create(hash_table_t *, hash_count_t, hash_count_t, 87 86 hash_table_operations_t *); 88 87 extern void hash_table_insert(hash_table_t *, unsigned long [], link_t *); -
uspace/lib/usb/Makefile
r5542b83 r969585f 53 53 src/hidreport.c \ 54 54 src/host/device_keeper.c \ 55 src/host/batch.c \ 56 src/host/bandwidth.c 55 src/host/batch.c 57 56 58 57 include $(USPACE_PREFIX)/Makefile.common -
uspace/lib/usb/include/usb/host/device_keeper.h
r5542b83 r969585f 51 51 usb_speed_t speed; 52 52 bool occupied; 53 uint16_tcontrol_used;53 bool control_used; 54 54 uint16_t toggle_status[2]; 55 55 devman_handle_t handle; … … 99 99 100 100 void usb_device_keeper_use_control(usb_device_keeper_t *instance, 101 usb_ target_t target);101 usb_address_t address); 102 102 103 103 void usb_device_keeper_release_control(usb_device_keeper_t *instance, 104 usb_ target_t target);104 usb_address_t address); 105 105 106 106 #endif -
uspace/lib/usb/src/host/device_keeper.c
r5542b83 r969585f 54 54 for (; i < USB_ADDRESS_COUNT; ++i) { 55 55 instance->devices[i].occupied = false; 56 instance->devices[i].control_used = 0;56 instance->devices[i].control_used = false; 57 57 instance->devices[i].handle = 0; 58 58 instance->devices[i].toggle_status[0] = 0; … … 311 311 /*----------------------------------------------------------------------------*/ 312 312 void usb_device_keeper_use_control(usb_device_keeper_t *instance, 313 usb_target_t target) 314 { 315 assert(instance); 316 const uint16_t ep = 1 << target.endpoint; 317 fibril_mutex_lock(&instance->guard); 318 while (instance->devices[target.address].control_used & ep) { 313 usb_address_t address) 314 { 315 assert(instance); 316 fibril_mutex_lock(&instance->guard); 317 while (instance->devices[address].control_used) { 319 318 fibril_condvar_wait(&instance->change, &instance->guard); 320 319 } 321 instance->devices[ target.address].control_used |= ep;320 instance->devices[address].control_used = true; 322 321 fibril_mutex_unlock(&instance->guard); 323 322 } 324 323 /*----------------------------------------------------------------------------*/ 325 324 void usb_device_keeper_release_control(usb_device_keeper_t *instance, 326 usb_target_t target) 327 { 328 assert(instance); 329 const uint16_t ep = 1 << target.endpoint; 330 fibril_mutex_lock(&instance->guard); 331 assert((instance->devices[target.address].control_used & ep) != 0); 332 instance->devices[target.address].control_used &= ~ep; 325 usb_address_t address) 326 { 327 assert(instance); 328 fibril_mutex_lock(&instance->guard); 329 instance->devices[address].control_used = false; 333 330 fibril_mutex_unlock(&instance->guard); 334 331 fibril_condvar_signal(&instance->change);
Note:
See TracChangeset
for help on using the changeset viewer.