Changes in / [50114ef:5f80527] in mainline
- Files:
-
- 8 added
- 8 deleted
- 14 edited
-
HelenOS.config (modified) (1 diff)
-
uspace/drv/ohci/iface.c (modified) (16 diffs)
-
uspace/drv/ohci/main.c (modified) (1 diff)
-
uspace/drv/uhci-hcd/Makefile (modified) (1 diff)
-
uspace/drv/uhci-hcd/batch.c (modified) (14 diffs)
-
uspace/drv/uhci-hcd/batch.h (modified) (1 diff)
-
uspace/drv/uhci-hcd/hc.c (deleted)
-
uspace/drv/uhci-hcd/hc.h (deleted)
-
uspace/drv/uhci-hcd/hw_struct/link_pointer.h (deleted)
-
uspace/drv/uhci-hcd/hw_struct/queue_head.h (deleted)
-
uspace/drv/uhci-hcd/hw_struct/transfer_descriptor.c (deleted)
-
uspace/drv/uhci-hcd/hw_struct/transfer_descriptor.h (deleted)
-
uspace/drv/uhci-hcd/iface.c (modified) (15 diffs)
-
uspace/drv/uhci-hcd/iface.h (modified) (1 diff)
-
uspace/drv/uhci-hcd/root_hub.c (deleted)
-
uspace/drv/uhci-hcd/root_hub.h (deleted)
-
uspace/drv/uhci-hcd/transfer_list.c (modified) (8 diffs)
-
uspace/drv/uhci-hcd/transfer_list.h (modified) (1 diff)
-
uspace/drv/uhci-hcd/uhci.c (modified) (9 diffs)
-
uspace/drv/uhci-hcd/uhci.h (modified) (2 diffs)
-
uspace/drv/uhci-hcd/uhci_hc.c (added)
-
uspace/drv/uhci-hcd/uhci_hc.h (added)
-
uspace/drv/uhci-hcd/uhci_rh.c (added)
-
uspace/drv/uhci-hcd/uhci_rh.h (added)
-
uspace/drv/uhci-hcd/uhci_struct/link_pointer.h (added)
-
uspace/drv/uhci-hcd/uhci_struct/queue_head.h (added)
-
uspace/drv/uhci-hcd/uhci_struct/transfer_descriptor.c (added)
-
uspace/drv/uhci-hcd/uhci_struct/transfer_descriptor.h (added)
-
uspace/drv/uhci-hcd/utils/malloc32.h (modified) (1 diff)
-
uspace/lib/usb/src/host/device_keeper.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
HelenOS.config
r50114ef r5f80527 552 552 ! CONFIG_RUN_VIRTUAL_USB_HC (n/y) 553 553 554 % Polling UHCI & OHCI (no interrupts)555 ! [PLATFORM=ia32|PLATFORM=amd64] CONFIG_USBHC_NO_INTERRUPTS (y/n) -
uspace/drv/ohci/iface.c
r50114ef r5f80527 33 33 */ 34 34 #include <ddf/driver.h> 35 #include <ddf/interrupt.h> 36 #include <device/hw_res.h> 35 37 #include <errno.h> 36 38 #include <str_error.h> 39 40 #include <usb_iface.h> 41 #include <usb/ddfiface.h> 37 42 #include <usb/debug.h> 38 43 … … 55 60 static int reserve_default_address(ddf_fun_t *fun, usb_speed_t speed) 56 61 { 57 assert(fun);58 hc_t *hc = fun_to_hc(fun);59 assert(hc);60 usb_log_debug("Default address request with speed %d.\n", speed);61 usb_device_keeper_reserve_default_address(&hc->manager, speed);62 return EOK;62 assert(fun); 63 hc_t *hc = fun_to_hc(fun); 64 assert(hc); 65 usb_log_debug("Default address request with speed %d.\n", speed); 66 usb_device_keeper_reserve_default_address(&hc->manager, speed); 67 return EOK; 63 68 } 64 69 /*----------------------------------------------------------------------------*/ … … 70 75 static int release_default_address(ddf_fun_t *fun) 71 76 { 72 assert(fun);73 hc_t *hc = fun_to_hc(fun);74 assert(hc);75 usb_log_debug("Default address release.\n");76 usb_device_keeper_release_default_address(&hc->manager);77 return EOK;77 assert(fun); 78 hc_t *hc = fun_to_hc(fun); 79 assert(hc); 80 usb_log_debug("Default address release.\n"); 81 usb_device_keeper_release_default_address(&hc->manager); 82 return EOK; 78 83 } 79 84 /*----------------------------------------------------------------------------*/ … … 85 90 * @return Error code. 86 91 */ 87 static int request_address( 88 ddf_fun_t *fun, usb_speed_t speed,usb_address_t *address)89 { 90 assert(fun);91 hc_t *hc = fun_to_hc(fun);92 assert(hc);93 assert(address);94 95 usb_log_debug("Address request with speed %d.\n", speed);96 *address = device_keeper_get_free_address(&hc->manager, speed);97 usb_log_debug("Address request with result: %d.\n", *address);98 if (*address <= 0)99 return *address;100 return EOK;92 static int request_address(ddf_fun_t *fun, usb_speed_t speed, 93 usb_address_t *address) 94 { 95 assert(fun); 96 hc_t *hc = fun_to_hc(fun); 97 assert(hc); 98 assert(address); 99 100 usb_log_debug("Address request with speed %d.\n", speed); 101 *address = device_keeper_get_free_address(&hc->manager, speed); 102 usb_log_debug("Address request with result: %d.\n", *address); 103 if (*address <= 0) 104 return *address; 105 return EOK; 101 106 } 102 107 /*----------------------------------------------------------------------------*/ … … 108 113 * @return Error code. 109 114 */ 110 static int bind_address( 111 ddf_fun_t *fun,usb_address_t address, devman_handle_t handle)112 { 113 assert(fun);114 hc_t *hc = fun_to_hc(fun);115 assert(hc);116 usb_log_debug("Address bind %d-%d.\n", address, handle);117 usb_device_keeper_bind(&hc->manager, address, handle);118 return EOK;115 static int bind_address(ddf_fun_t *fun, 116 usb_address_t address, devman_handle_t handle) 117 { 118 assert(fun); 119 hc_t *hc = fun_to_hc(fun); 120 assert(hc); 121 usb_log_debug("Address bind %d-%d.\n", address, handle); 122 usb_device_keeper_bind(&hc->manager, address, handle); 123 return EOK; 119 124 } 120 125 /*----------------------------------------------------------------------------*/ … … 127 132 static int release_address(ddf_fun_t *fun, usb_address_t address) 128 133 { 129 assert(fun);130 hc_t *hc = fun_to_hc(fun);131 assert(hc);132 usb_log_debug("Address release %d.\n", address);133 usb_device_keeper_release(&hc->manager, address);134 return EOK;135 } 136 /*----------------------------------------------------------------------------*/ 134 assert(fun); 135 hc_t *hc = fun_to_hc(fun); 136 assert(hc); 137 usb_log_debug("Address release %d.\n", address); 138 usb_device_keeper_release(&hc->manager, address); 139 return EOK; 140 } 141 137 142 /** Register endpoint for bandwidth reservation. 138 143 * … … 146 151 * @return Error code. 147 152 */ 148 static int register_endpoint( 149 ddf_fun_t *fun,usb_address_t address, usb_endpoint_t endpoint,153 static int register_endpoint(ddf_fun_t *fun, 154 usb_address_t address, usb_endpoint_t endpoint, 150 155 usb_transfer_type_t transfer_type, usb_direction_t direction, 151 156 size_t max_packet_size, unsigned int interval) … … 155 160 return ENOTSUP; 156 161 } 157 /*----------------------------------------------------------------------------*/ 162 158 163 /** Unregister endpoint (free some bandwidth reservation). 159 164 * … … 164 169 * @return Error code. 165 170 */ 166 static int unregister_endpoint( 167 ddf_fun_t *fun, usb_address_t address, 171 static int unregister_endpoint(ddf_fun_t *fun, usb_address_t address, 168 172 usb_endpoint_t endpoint, usb_direction_t direction) 169 173 { … … 190 194 * @return Error code. 191 195 */ 192 static int interrupt_out( 193 ddf_fun_t *fun, usb_target_t target, size_t max_packet_size, void *data, 194 size_t size, usbhc_iface_transfer_out_callback_t callback, void *arg) 195 { 196 assert(fun); 197 hc_t *hc = fun_to_hc(fun); 198 assert(hc); 199 usb_speed_t speed = 200 usb_device_keeper_get_speed(&hc->manager, target.address); 201 202 usb_log_debug("Interrupt OUT %d:%d %zu(%zu).\n", 203 target.address, target.endpoint, size, max_packet_size); 204 205 usb_transfer_batch_t *batch = 206 batch_get(fun, target, USB_TRANSFER_INTERRUPT, max_packet_size, 207 speed, data, size, NULL, 0, NULL, callback, arg, &hc->manager); 208 if (!batch) 209 return ENOMEM; 210 batch_interrupt_out(batch); 211 const int ret = hc_schedule(hc, batch); 212 if (ret != EOK) { 213 batch_dispose(batch); 214 } 215 return ret; 196 static int interrupt_out(ddf_fun_t *fun, usb_target_t target, 197 size_t max_packet_size, void *data, size_t size, 198 usbhc_iface_transfer_out_callback_t callback, void *arg) 199 { 200 hc_t *hc = fun_to_hc(fun); 201 assert(hc); 202 usb_speed_t speed = usb_device_keeper_get_speed(&hc->manager, target.address); 203 204 usb_log_debug("Interrupt OUT %d:%d %zu(%zu).\n", 205 target.address, target.endpoint, size, max_packet_size); 206 207 usb_transfer_batch_t *batch = batch_get(fun, target, USB_TRANSFER_INTERRUPT, 208 max_packet_size, speed, data, size, NULL, 0, NULL, callback, arg, 209 &hc->manager); 210 if (!batch) 211 return ENOMEM; 212 batch_interrupt_out(batch); 213 const int ret = hc_schedule(hc, batch); 214 if (ret != EOK) { 215 batch_dispose(batch); 216 return ret; 217 } 218 return EOK; 216 219 } 217 220 /*----------------------------------------------------------------------------*/ … … 233 236 * @return Error code. 234 237 */ 235 static int interrupt_in( 236 ddf_fun_t *fun, usb_target_t target, size_t max_packet_size, void *data,237 size_t size,usbhc_iface_transfer_in_callback_t callback, void *arg)238 { 239 assert(fun);240 hc_t *hc = fun_to_hc(fun);241 assert(hc);242 usb_speed_t speed = 243 usb_device_keeper_get_speed(&hc->manager, target.address); 244 usb_log_debug("Interrupt IN %d:%d %zu(%zu).\n", 245 target.address, target.endpoint, size, max_packet_size); 246 247 usb_transfer_batch_t *batch = 248 batch_get(fun, target, USB_TRANSFER_INTERRUPT, max_packet_size, 249 speed, data, size, NULL, 0, callback, NULL, arg, &hc->manager); 250 if (!batch) 251 return ENOMEM;252 batch_interrupt_in(batch);253 const int ret = hc_schedule(hc, batch); 254 if (ret != EOK) { 255 batch_dispose(batch);256 }257 return ret;238 static int interrupt_in(ddf_fun_t *fun, usb_target_t target, 239 size_t max_packet_size, void *data, size_t size, 240 usbhc_iface_transfer_in_callback_t callback, void *arg) 241 { 242 assert(fun); 243 hc_t *hc = fun_to_hc(fun); 244 assert(hc); 245 usb_speed_t speed = usb_device_keeper_get_speed(&hc->manager, target.address); 246 usb_log_debug("Interrupt IN %d:%d %zu(%zu).\n", 247 target.address, target.endpoint, size, max_packet_size); 248 249 usb_transfer_batch_t *batch = batch_get(fun, target, USB_TRANSFER_INTERRUPT, 250 max_packet_size, speed, data, size, NULL, 0, callback, NULL, arg, 251 &hc->manager); 252 if (!batch) 253 return ENOMEM; 254 batch_interrupt_in(batch); 255 const int ret = hc_schedule(hc, batch); 256 if (ret != EOK) { 257 batch_dispose(batch); 258 return ret; 259 } 260 return EOK; 258 261 } 259 262 /*----------------------------------------------------------------------------*/ … … 275 278 * @return Error code. 276 279 */ 277 static int bulk_out( 278 ddf_fun_t *fun, usb_target_t target, size_t max_packet_size, void *data, 279 size_t size, usbhc_iface_transfer_out_callback_t callback, void *arg) 280 { 281 assert(fun); 282 hc_t *hc = fun_to_hc(fun); 283 assert(hc); 284 usb_speed_t speed = 285 usb_device_keeper_get_speed(&hc->manager, target.address); 286 287 usb_log_debug("Bulk OUT %d:%d %zu(%zu).\n", 288 target.address, target.endpoint, size, max_packet_size); 289 290 usb_transfer_batch_t *batch = 291 batch_get(fun, target, USB_TRANSFER_BULK, max_packet_size, speed, 292 data, size, NULL, 0, NULL, callback, arg, &hc->manager); 293 if (!batch) 294 return ENOMEM; 295 batch_bulk_out(batch); 296 const int ret = hc_schedule(hc, batch); 297 if (ret != EOK) { 298 batch_dispose(batch); 299 } 300 return ret; 280 static int bulk_out(ddf_fun_t *fun, usb_target_t target, 281 size_t max_packet_size, void *data, size_t size, 282 usbhc_iface_transfer_out_callback_t callback, void *arg) 283 { 284 assert(fun); 285 hc_t *hc = fun_to_hc(fun); 286 assert(hc); 287 usb_speed_t speed = usb_device_keeper_get_speed(&hc->manager, target.address); 288 289 usb_log_debug("Bulk OUT %d:%d %zu(%zu).\n", 290 target.address, target.endpoint, size, max_packet_size); 291 292 usb_transfer_batch_t *batch = batch_get(fun, target, USB_TRANSFER_BULK, 293 max_packet_size, speed, data, size, NULL, 0, NULL, callback, arg, 294 &hc->manager); 295 if (!batch) 296 return ENOMEM; 297 batch_bulk_out(batch); 298 const int ret = hc_schedule(hc, batch); 299 if (ret != EOK) { 300 batch_dispose(batch); 301 return ret; 302 } 303 return EOK; 304 301 305 } 302 306 /*----------------------------------------------------------------------------*/ … … 318 322 * @return Error code. 319 323 */ 320 static int bulk_in( 321 ddf_fun_t *fun, usb_target_t target, size_t max_packet_size, void *data,322 size_t size,usbhc_iface_transfer_in_callback_t callback, void *arg)323 { 324 assert(fun);325 hc_t *hc = fun_to_hc(fun);326 assert(hc);327 usb_speed_t speed = 328 usb_device_keeper_get_speed(&hc->manager, target.address); 329 usb_log_debug("Bulk IN %d:%d %zu(%zu).\n", 330 target.address, target.endpoint, size, max_packet_size); 331 332 usb_transfer_batch_t *batch = 333 batch_get(fun, target, USB_TRANSFER_BULK, max_packet_size, speed, 334 data, size, NULL, 0, callback, NULL, arg, &hc->manager); 335 if (!batch) 336 return ENOMEM;337 batch_bulk_in(batch);338 const int ret = hc_schedule(hc, batch); 339 if (ret != EOK) { 340 batch_dispose(batch);341 }342 return ret;324 static int bulk_in(ddf_fun_t *fun, usb_target_t target, 325 size_t max_packet_size, void *data, size_t size, 326 usbhc_iface_transfer_in_callback_t callback, void *arg) 327 { 328 assert(fun); 329 hc_t *hc = fun_to_hc(fun); 330 assert(hc); 331 usb_speed_t speed = usb_device_keeper_get_speed(&hc->manager, target.address); 332 usb_log_debug("Bulk IN %d:%d %zu(%zu).\n", 333 target.address, target.endpoint, size, max_packet_size); 334 335 usb_transfer_batch_t *batch = batch_get(fun, target, USB_TRANSFER_BULK, 336 max_packet_size, speed, data, size, NULL, 0, callback, NULL, arg, 337 &hc->manager); 338 if (!batch) 339 return ENOMEM; 340 batch_bulk_in(batch); 341 const int ret = hc_schedule(hc, batch); 342 if (ret != EOK) { 343 batch_dispose(batch); 344 return ret; 345 } 346 return EOK; 343 347 } 344 348 /*----------------------------------------------------------------------------*/ … … 363 367 * @return Error code. 364 368 */ 365 static int control_write( 366 ddf_fun_t *fun, usb_target_t target, size_t max_packet_size, 367 void *setup_data, size_t setup_size, void *data, size_t size, 369 static int control_write(ddf_fun_t *fun, usb_target_t target, 370 size_t max_packet_size, 371 void *setup_data, size_t setup_size, 372 void *data, size_t size, 368 373 usbhc_iface_transfer_out_callback_t callback, void *arg) 369 374 { 370 assert(fun); 371 hc_t *hc = fun_to_hc(fun); 372 assert(hc); 373 usb_speed_t speed = 374 usb_device_keeper_get_speed(&hc->manager, target.address); 375 usb_log_debug("Control WRITE (%d) %d:%d %zu(%zu).\n", 376 speed, target.address, target.endpoint, size, max_packet_size); 377 378 if (setup_size != 8) 379 return EINVAL; 380 381 usb_transfer_batch_t *batch = 382 batch_get(fun, target, USB_TRANSFER_CONTROL, max_packet_size, 383 speed, data, size, setup_data, setup_size, NULL, callback, arg, 384 &hc->manager); 385 if (!batch) 386 return ENOMEM; 387 usb_device_keeper_reset_if_need(&hc->manager, target, setup_data); 388 batch_control_write(batch); 389 const int ret = hc_schedule(hc, batch); 390 if (ret != EOK) { 391 batch_dispose(batch); 392 } 393 return ret; 375 assert(fun); 376 hc_t *hc = fun_to_hc(fun); 377 assert(hc); 378 usb_speed_t speed = usb_device_keeper_get_speed(&hc->manager, target.address); 379 usb_log_debug("Control WRITE (%d) %d:%d %zu(%zu).\n", 380 speed, target.address, target.endpoint, size, max_packet_size); 381 382 if (setup_size != 8) 383 return EINVAL; 384 385 usb_transfer_batch_t *batch = batch_get(fun, target, USB_TRANSFER_CONTROL, 386 max_packet_size, speed, data, size, setup_data, setup_size, 387 NULL, callback, arg, &hc->manager); 388 if (!batch) 389 return ENOMEM; 390 usb_device_keeper_reset_if_need(&hc->manager, target, setup_data); 391 batch_control_write(batch); 392 const int ret = hc_schedule(hc, batch); 393 if (ret != EOK) { 394 batch_dispose(batch); 395 return ret; 396 } 397 return EOK; 394 398 } 395 399 /*----------------------------------------------------------------------------*/ … … 414 418 * @return Error code. 415 419 */ 416 static int control_read( 417 ddf_fun_t *fun, usb_target_t target, size_t max_packet_size, 418 void *setup_data, size_t setup_size, void *data, size_t size, 420 static int control_read(ddf_fun_t *fun, usb_target_t target, 421 size_t max_packet_size, 422 void *setup_data, size_t setup_size, 423 void *data, size_t size, 419 424 usbhc_iface_transfer_in_callback_t callback, void *arg) 420 425 { 421 assert(fun); 422 hc_t *hc = fun_to_hc(fun); 423 assert(hc); 424 usb_speed_t speed = 425 usb_device_keeper_get_speed(&hc->manager, target.address); 426 427 usb_log_debug("Control READ(%d) %d:%d %zu(%zu).\n", 428 speed, target.address, target.endpoint, size, max_packet_size); 429 usb_transfer_batch_t *batch = 430 batch_get(fun, target, USB_TRANSFER_CONTROL, max_packet_size, 431 speed, data, size, setup_data, setup_size, callback, NULL, arg, 432 &hc->manager); 433 if (!batch) 434 return ENOMEM; 435 batch_control_read(batch); 436 const int ret = hc_schedule(hc, batch); 437 if (ret != EOK) { 438 batch_dispose(batch); 439 } 440 return ret; 426 assert(fun); 427 hc_t *hc = fun_to_hc(fun); 428 assert(hc); 429 usb_speed_t speed = usb_device_keeper_get_speed(&hc->manager, target.address); 430 431 usb_log_debug("Control READ(%d) %d:%d %zu(%zu).\n", 432 speed, target.address, target.endpoint, size, max_packet_size); 433 usb_transfer_batch_t *batch = batch_get(fun, target, USB_TRANSFER_CONTROL, 434 max_packet_size, speed, data, size, setup_data, setup_size, callback, 435 NULL, arg, &hc->manager); 436 if (!batch) 437 return ENOMEM; 438 batch_control_read(batch); 439 const int ret = hc_schedule(hc, batch); 440 if (ret != EOK) { 441 batch_dispose(batch); 442 return ret; 443 } 444 return EOK; 441 445 } 442 446 /*----------------------------------------------------------------------------*/ … … 459 463 460 464 .control_write = control_write, 461 .control_read = control_read ,465 .control_read = control_read 462 466 }; 463 467 -
uspace/drv/ohci/main.c
r50114ef r5f80527 149 149 } 150 150 151 152 151 bool interrupts = false; 153 #ifdef CONFIG_USBHC_NO_INTERRUPTS154 usb_log_warning("Interrupts disabled in OS config, " \155 "falling back to polling.\n");156 #else157 152 ret = pci_enable_interrupts(device); 158 153 if (ret != EOK) { 159 usb_log_warning("Failed to enable interrupts: %s.\n", 160 str_error(ret)); 161 usb_log_info("HW interrupts not available, " \ 162 "falling back to polling.\n"); 154 usb_log_warning( 155 "Failed(%d) to enable interrupts, fall back to polling.\n", 156 ret); 163 157 } else { 164 158 usb_log_debug("Hw interrupts enabled.\n"); 165 159 interrupts = true; 166 160 } 167 #endif168 161 169 162 ret = hc_init(hcd, hc_fun, device, mem_reg_base, mem_reg_size, interrupts); -
uspace/drv/uhci-hcd/Makefile
r50114ef r5f80527 37 37 transfer_list.c \ 38 38 uhci.c \ 39 hc.c \40 root_hub.c \41 hw_struct/transfer_descriptor.c \39 uhci_hc.c \ 40 uhci_rh.c \ 41 uhci_struct/transfer_descriptor.c \ 42 42 pci.c \ 43 43 batch.c -
uspace/drv/uhci-hcd/batch.c
r50114ef r5f80527 40 40 #include "batch.h" 41 41 #include "transfer_list.h" 42 #include " hw_struct/transfer_descriptor.h"42 #include "uhci_hc.h" 43 43 #include "utils/malloc32.h" 44 #include "uhci_struct/transfer_descriptor.h" 44 45 45 46 #define DEFAULT_ERROR_COUNT 3 … … 48 49 qh_t *qh; 49 50 td_t *tds; 50 size_t transfers;51 size_t packets; 51 52 usb_device_keeper_t *manager; 52 53 } uhci_batch_t; … … 64 65 * @param[in] target Device and endpoint target of the transaction. 65 66 * @param[in] transfer_type Interrupt, Control or Bulk. 66 * @param[in] max_packet_size maximum allowed size of data transfers.67 * @param[in] max_packet_size maximum allowed size of data packets. 67 68 * @param[in] speed Speed of the transaction. 68 69 * @param[in] buffer Data source/destination. … … 77 78 * NULL otherwise. 78 79 * 79 * Determines the number of needed transfers (TDs). Prepares a transport buffer80 * Determines the number of needed packets (TDs). Prepares a transport buffer 80 81 * (that is accessible by the hardware). Initializes parameters needed for the 81 82 * transaction and callback. … … 117 118 instance->private_data = data; 118 119 119 data-> transfers = (buffer_size + max_packet_size - 1) / max_packet_size;120 data->packets = (buffer_size + max_packet_size - 1) / max_packet_size; 120 121 if (transfer_type == USB_TRANSFER_CONTROL) { 121 data-> transfers += 2;122 } 123 124 data->tds = malloc32(sizeof(td_t) * data-> transfers);122 data->packets += 2; 123 } 124 125 data->tds = malloc32(sizeof(td_t) * data->packets); 125 126 CHECK_NULL_DISPOSE_RETURN( 126 127 data->tds, "Failed to allocate transfer descriptors.\n"); 127 bzero(data->tds, sizeof(td_t) * data-> transfers);128 bzero(data->tds, sizeof(td_t) * data->packets); 128 129 129 130 data->qh = malloc32(sizeof(qh_t)); … … 166 167 assert(data); 167 168 168 usb_log_debug2("Batch(%p) checking %d transfer(s) for completion.\n",169 instance, data-> transfers);169 usb_log_debug2("Batch(%p) checking %d packet(s) for completion.\n", 170 instance, data->packets); 170 171 instance->transfered_size = 0; 171 172 size_t i = 0; 172 for (;i < data-> transfers; ++i) {173 for (;i < data->packets; ++i) { 173 174 if (td_is_active(&data->tds[i])) { 174 175 return false; … … 298 299 * 299 300 * @param[in] instance Batch structure to use. 300 * @param[in] pid Pid to use for data transfers.301 * @param[in] pid to use for data packets. 301 302 * 302 303 * Packets with alternating toggle bit and supplied pid value. 303 * The last transferis marked with IOC flag.304 * The last packet is marked with IOC flag. 304 305 */ 305 306 void batch_data(usb_transfer_batch_t *instance, usb_packet_id pid) … … 314 315 assert(toggle == 0 || toggle == 1); 315 316 316 size_t transfer= 0;317 size_t packet = 0; 317 318 size_t remain_size = instance->buffer_size; 318 319 while (remain_size > 0) { … … 325 326 remain_size : instance->max_packet_size; 326 327 327 td_t *next_ transfer = (transfer + 1 < data->transfers)328 ? &data->tds[ transfer+ 1] : NULL;329 330 assert( transfer < data->transfers);328 td_t *next_packet = (packet + 1 < data->packets) 329 ? &data->tds[packet + 1] : NULL; 330 331 assert(packet < data->packets); 331 332 assert(packet_size <= remain_size); 332 333 333 334 td_init( 334 &data->tds[ transfer], DEFAULT_ERROR_COUNT, packet_size,335 &data->tds[packet], DEFAULT_ERROR_COUNT, packet_size, 335 336 toggle, false, low_speed, instance->target, pid, trans_data, 336 next_ transfer);337 next_packet); 337 338 338 339 339 340 toggle = 1 - toggle; 340 341 remain_size -= packet_size; 341 ++ transfer;342 } 343 td_set_ioc(&data->tds[ transfer- 1]);342 ++packet; 343 } 344 td_set_ioc(&data->tds[packet - 1]); 344 345 usb_device_keeper_set_toggle(data->manager, instance->target, 345 346 instance->direction, toggle); … … 349 350 * 350 351 * @param[in] instance Batch structure to use. 351 * @param[in] data_stage Pid to use for data transfers.352 * @param[in] status_stage Pid to use for data transfers.352 * @param[in] data_stage to use for data packets. 353 * @param[in] status_stage to use for data packets. 353 354 * 354 355 * Setup stage with toggle 0 and USB_PID_SETUP. 355 356 * Data stage with alternating toggle and pid supplied by parameter. 356 357 * Status stage with toggle 1 and pid supplied by parameter. 357 * The last transferis marked with IOC.358 * The last packet is marked with IOC. 358 359 */ 359 360 void batch_control(usb_transfer_batch_t *instance, … … 363 364 uhci_batch_t *data = instance->private_data; 364 365 assert(data); 365 assert(data-> transfers >= 2);366 assert(data->packets >= 2); 366 367 367 368 const bool low_speed = instance->speed == USB_SPEED_LOW; … … 374 375 375 376 /* data stage */ 376 size_t transfer= 1;377 size_t packet = 1; 377 378 size_t remain_size = instance->buffer_size; 378 379 while (remain_size > 0) { … … 388 389 389 390 td_init( 390 &data->tds[ transfer], DEFAULT_ERROR_COUNT, packet_size,391 &data->tds[packet], DEFAULT_ERROR_COUNT, packet_size, 391 392 toggle, false, low_speed, instance->target, data_stage, 392 control_data, &data->tds[ transfer+ 1]);393 394 ++ transfer;395 assert( transfer < data->transfers);393 control_data, &data->tds[packet + 1]); 394 395 ++packet; 396 assert(packet < data->packets); 396 397 assert(packet_size <= remain_size); 397 398 remain_size -= packet_size; … … 399 400 400 401 /* status stage */ 401 assert( transfer == data->transfers - 1);402 assert(packet == data->packets - 1); 402 403 403 404 td_init( 404 &data->tds[ transfer], DEFAULT_ERROR_COUNT, 0, 1, false, low_speed,405 &data->tds[packet], DEFAULT_ERROR_COUNT, 0, 1, false, low_speed, 405 406 instance->target, status_stage, NULL, NULL); 406 td_set_ioc(&data->tds[ transfer]);407 td_set_ioc(&data->tds[packet]); 407 408 408 409 usb_log_debug2("Control last TD status: %x.\n", 409 data->tds[ transfer].status);410 data->tds[packet].status); 410 411 } 411 412 /*----------------------------------------------------------------------------*/ -
uspace/drv/uhci-hcd/batch.h
r50114ef r5f80527 42 42 #include <usb/host/batch.h> 43 43 44 #include " hw_struct/queue_head.h"44 #include "uhci_struct/queue_head.h" 45 45 46 46 usb_transfer_batch_t * batch_get( -
uspace/drv/uhci-hcd/iface.c
r50114ef r5f80527 33 33 */ 34 34 #include <ddf/driver.h> 35 #include <remote_usbhc.h> 36 37 #include <usb/debug.h> 38 35 39 #include <errno.h> 36 40 37 #include <usb/debug.h>38 39 41 #include "iface.h" 40 #include " hc.h"42 #include "uhci_hc.h" 41 43 42 44 /** Reserve default address interface function … … 46 48 * @return Error code. 47 49 */ 50 /*----------------------------------------------------------------------------*/ 48 51 static int reserve_default_address(ddf_fun_t *fun, usb_speed_t speed) 49 52 { 50 53 assert(fun); 51 hc_t *hc = fun_to_hc(fun);54 uhci_hc_t *hc = fun_to_uhci_hc(fun); 52 55 assert(hc); 53 56 usb_log_debug("Default address request with speed %d.\n", speed); 54 usb_device_keeper_reserve_default_address(&hc-> manager, speed);57 usb_device_keeper_reserve_default_address(&hc->device_manager, speed); 55 58 return EOK; 56 59 } … … 64 67 { 65 68 assert(fun); 66 hc_t *hc = fun_to_hc(fun);69 uhci_hc_t *hc = fun_to_uhci_hc(fun); 67 70 assert(hc); 68 71 usb_log_debug("Default address release.\n"); 69 usb_device_keeper_release_default_address(&hc-> manager);72 usb_device_keeper_release_default_address(&hc->device_manager); 70 73 return EOK; 71 74 } … … 78 81 * @return Error code. 79 82 */ 80 static int request_address( 81 ddf_fun_t *fun, usb_speed_t speed,usb_address_t *address)82 { 83 assert(fun); 84 hc_t *hc = fun_to_hc(fun);83 static int request_address(ddf_fun_t *fun, usb_speed_t speed, 84 usb_address_t *address) 85 { 86 assert(fun); 87 uhci_hc_t *hc = fun_to_uhci_hc(fun); 85 88 assert(hc); 86 89 assert(address); 87 90 88 91 usb_log_debug("Address request with speed %d.\n", speed); 89 *address = device_keeper_get_free_address(&hc-> manager, speed);92 *address = device_keeper_get_free_address(&hc->device_manager, speed); 90 93 usb_log_debug("Address request with result: %d.\n", *address); 91 94 if (*address <= 0) 92 return *address;95 return *address; 93 96 return EOK; 94 97 } … … 105 108 { 106 109 assert(fun); 107 hc_t *hc = fun_to_hc(fun);110 uhci_hc_t *hc = fun_to_uhci_hc(fun); 108 111 assert(hc); 109 112 usb_log_debug("Address bind %d-%d.\n", address, handle); 110 usb_device_keeper_bind(&hc-> manager, address, handle);113 usb_device_keeper_bind(&hc->device_manager, address, handle); 111 114 return EOK; 112 115 } … … 121 124 { 122 125 assert(fun); 123 hc_t *hc = fun_to_hc(fun);126 uhci_hc_t *hc = fun_to_uhci_hc(fun); 124 127 assert(hc); 125 128 usb_log_debug("Address release %d.\n", address); 126 usb_device_keeper_release(&hc-> manager, address);129 usb_device_keeper_release(&hc->device_manager, address); 127 130 return EOK; 128 131 } … … 139 142 * @return Error code. 140 143 */ 141 static int interrupt_out( 142 ddf_fun_t *fun, usb_target_t target, size_t max_packet_size, void *data, 143 size_t size, usbhc_iface_transfer_out_callback_t callback, void *arg) 144 { 145 assert(fun); 146 hc_t *hc = fun_to_hc(fun); 147 assert(hc); 148 usb_speed_t speed = 149 usb_device_keeper_get_speed(&hc->manager, target.address); 144 static int interrupt_out(ddf_fun_t *fun, usb_target_t target, 145 size_t max_packet_size, void *data, size_t size, 146 usbhc_iface_transfer_out_callback_t callback, void *arg) 147 { 148 assert(fun); 149 uhci_hc_t *hc = fun_to_uhci_hc(fun); 150 assert(hc); 151 usb_speed_t speed = usb_device_keeper_get_speed(&hc->device_manager, target.address); 150 152 151 153 usb_log_debug("Interrupt OUT %d:%d %zu(%zu).\n", 152 154 target.address, target.endpoint, size, max_packet_size); 153 155 154 usb_transfer_batch_t *batch = 155 batch_get(fun, target, USB_TRANSFER_INTERRUPT, max_packet_size,156 speed, data, size, NULL, 0, NULL, callback, arg, &hc->manager);156 usb_transfer_batch_t *batch = batch_get(fun, target, USB_TRANSFER_INTERRUPT, 157 max_packet_size, speed, data, size, NULL, 0, NULL, callback, arg, 158 &hc->device_manager); 157 159 if (!batch) 158 160 return ENOMEM; 159 161 batch_interrupt_out(batch); 160 const int ret = hc_schedule(hc, batch); 161 if (ret != EOK) { 162 batch_dispose(batch); 163 } 164 return ret; 162 const int ret = uhci_hc_schedule(hc, batch); 163 if (ret != EOK) { 164 batch_dispose(batch); 165 return ret; 166 } 167 return EOK; 165 168 } 166 169 /*----------------------------------------------------------------------------*/ … … 176 179 * @return Error code. 177 180 */ 178 static int interrupt_in( 179 ddf_fun_t *fun, usb_target_t target, size_t max_packet_size, void *data, 180 size_t size, usbhc_iface_transfer_in_callback_t callback, void *arg) 181 { 182 assert(fun); 183 hc_t *hc = fun_to_hc(fun); 184 assert(hc); 185 usb_speed_t speed = 186 usb_device_keeper_get_speed(&hc->manager, target.address); 181 static int interrupt_in(ddf_fun_t *fun, usb_target_t target, 182 size_t max_packet_size, void *data, size_t size, 183 usbhc_iface_transfer_in_callback_t callback, void *arg) 184 { 185 assert(fun); 186 uhci_hc_t *hc = fun_to_uhci_hc(fun); 187 assert(hc); 188 usb_speed_t speed = usb_device_keeper_get_speed(&hc->device_manager, target.address); 187 189 usb_log_debug("Interrupt IN %d:%d %zu(%zu).\n", 188 190 target.address, target.endpoint, size, max_packet_size); 189 191 190 usb_transfer_batch_t *batch = 191 batch_get(fun, target, USB_TRANSFER_INTERRUPT, max_packet_size,192 speed, data, size, NULL, 0, callback, NULL, arg, &hc->manager);192 usb_transfer_batch_t *batch = batch_get(fun, target, USB_TRANSFER_INTERRUPT, 193 max_packet_size, speed, data, size, NULL, 0, callback, NULL, arg, 194 &hc->device_manager); 193 195 if (!batch) 194 196 return ENOMEM; 195 197 batch_interrupt_in(batch); 196 const int ret = hc_schedule(hc, batch); 197 if (ret != EOK) { 198 batch_dispose(batch); 199 } 200 return ret; 198 const int ret = uhci_hc_schedule(hc, batch); 199 if (ret != EOK) { 200 batch_dispose(batch); 201 return ret; 202 } 203 return EOK; 201 204 } 202 205 /*----------------------------------------------------------------------------*/ … … 212 215 * @return Error code. 213 216 */ 214 static int bulk_out( 215 ddf_fun_t *fun, usb_target_t target, size_t max_packet_size, void *data, 216 size_t size, usbhc_iface_transfer_out_callback_t callback, void *arg) 217 { 218 assert(fun); 219 hc_t *hc = fun_to_hc(fun); 220 assert(hc); 221 usb_speed_t speed = 222 usb_device_keeper_get_speed(&hc->manager, target.address); 217 static int bulk_out(ddf_fun_t *fun, usb_target_t target, 218 size_t max_packet_size, void *data, size_t size, 219 usbhc_iface_transfer_out_callback_t callback, void *arg) 220 { 221 assert(fun); 222 uhci_hc_t *hc = fun_to_uhci_hc(fun); 223 assert(hc); 224 usb_speed_t speed = usb_device_keeper_get_speed(&hc->device_manager, target.address); 223 225 224 226 usb_log_debug("Bulk OUT %d:%d %zu(%zu).\n", 225 227 target.address, target.endpoint, size, max_packet_size); 226 228 227 usb_transfer_batch_t *batch = 228 batch_get(fun, target, USB_TRANSFER_BULK, max_packet_size, speed,229 data, size, NULL, 0, NULL, callback, arg, &hc->manager);229 usb_transfer_batch_t *batch = batch_get(fun, target, USB_TRANSFER_BULK, 230 max_packet_size, speed, data, size, NULL, 0, NULL, callback, arg, 231 &hc->device_manager); 230 232 if (!batch) 231 233 return ENOMEM; 232 234 batch_bulk_out(batch); 233 const int ret = hc_schedule(hc, batch); 234 if (ret != EOK) { 235 batch_dispose(batch); 236 } 237 return ret; 235 const int ret = uhci_hc_schedule(hc, batch); 236 if (ret != EOK) { 237 batch_dispose(batch); 238 return ret; 239 } 240 return EOK; 238 241 } 239 242 /*----------------------------------------------------------------------------*/ … … 249 252 * @return Error code. 250 253 */ 251 static int bulk_in( 252 ddf_fun_t *fun, usb_target_t target, size_t max_packet_size, void *data, 253 size_t size, usbhc_iface_transfer_in_callback_t callback, void *arg) 254 { 255 assert(fun); 256 hc_t *hc = fun_to_hc(fun); 257 assert(hc); 258 usb_speed_t speed = 259 usb_device_keeper_get_speed(&hc->manager, target.address); 254 static int bulk_in(ddf_fun_t *fun, usb_target_t target, 255 size_t max_packet_size, void *data, size_t size, 256 usbhc_iface_transfer_in_callback_t callback, void *arg) 257 { 258 assert(fun); 259 uhci_hc_t *hc = fun_to_uhci_hc(fun); 260 assert(hc); 261 usb_speed_t speed = usb_device_keeper_get_speed(&hc->device_manager, target.address); 260 262 usb_log_debug("Bulk IN %d:%d %zu(%zu).\n", 261 263 target.address, target.endpoint, size, max_packet_size); 262 264 263 usb_transfer_batch_t *batch = 264 batch_get(fun, target, USB_TRANSFER_BULK, max_packet_size, speed,265 data, size, NULL, 0, callback, NULL, arg, &hc->manager);265 usb_transfer_batch_t *batch = batch_get(fun, target, USB_TRANSFER_BULK, 266 max_packet_size, speed, data, size, NULL, 0, callback, NULL, arg, 267 &hc->device_manager); 266 268 if (!batch) 267 269 return ENOMEM; 268 270 batch_bulk_in(batch); 269 const int ret = hc_schedule(hc, batch); 270 if (ret != EOK) { 271 batch_dispose(batch); 272 } 273 return ret; 271 const int ret = uhci_hc_schedule(hc, batch); 272 if (ret != EOK) { 273 batch_dispose(batch); 274 return ret; 275 } 276 return EOK; 274 277 } 275 278 /*----------------------------------------------------------------------------*/ … … 279 282 * @param[in] target USB device to write to. 280 283 * @param[in] max_packet_size maximum size of data packet the device accepts. 281 * @param[in] setup_data Data to send with SETUP transfer.282 * @param[in] setup_size Size of data to send with SETUP transfer (always8B).284 * @param[in] setup_data Data to send with SETUP packet. 285 * @param[in] setup_size Size of data to send with SETUP packet (should be 8B). 283 286 * @param[in] data Source of data. 284 287 * @param[in] size Size of data source. … … 287 290 * @return Error code. 288 291 */ 289 static int control_write( 290 ddf_fun_t *fun, usb_target_t target,size_t max_packet_size,292 static int control_write(ddf_fun_t *fun, usb_target_t target, 293 size_t max_packet_size, 291 294 void *setup_data, size_t setup_size, void *data, size_t size, 292 295 usbhc_iface_transfer_out_callback_t callback, void *arg) 293 296 { 294 297 assert(fun); 295 hc_t *hc = fun_to_hc(fun); 296 assert(hc); 297 usb_speed_t speed = 298 usb_device_keeper_get_speed(&hc->manager, target.address); 298 uhci_hc_t *hc = fun_to_uhci_hc(fun); 299 assert(hc); 300 usb_speed_t speed = usb_device_keeper_get_speed(&hc->device_manager, target.address); 299 301 usb_log_debug("Control WRITE (%d) %d:%d %zu(%zu).\n", 300 302 speed, target.address, target.endpoint, size, max_packet_size); … … 303 305 return EINVAL; 304 306 305 usb_transfer_batch_t *batch = 306 batch_get(fun, target, USB_TRANSFER_CONTROL, max_packet_size, speed, 307 data, size, setup_data, setup_size, NULL, callback, arg, 308 &hc->manager); 309 if (!batch) 310 return ENOMEM; 311 usb_device_keeper_reset_if_need(&hc->manager, target, setup_data); 307 usb_transfer_batch_t *batch = batch_get(fun, target, USB_TRANSFER_CONTROL, 308 max_packet_size, speed, data, size, setup_data, setup_size, 309 NULL, callback, arg, &hc->device_manager); 310 if (!batch) 311 return ENOMEM; 312 usb_device_keeper_reset_if_need(&hc->device_manager, target, setup_data); 312 313 batch_control_write(batch); 313 const int ret = hc_schedule(hc, batch); 314 if (ret != EOK) { 315 batch_dispose(batch); 316 } 317 return ret; 314 const int ret = uhci_hc_schedule(hc, batch); 315 if (ret != EOK) { 316 batch_dispose(batch); 317 return ret; 318 } 319 return EOK; 318 320 } 319 321 /*----------------------------------------------------------------------------*/ … … 331 333 * @return Error code. 332 334 */ 333 static int control_read( 334 ddf_fun_t *fun, usb_target_t target,size_t max_packet_size,335 static int control_read(ddf_fun_t *fun, usb_target_t target, 336 size_t max_packet_size, 335 337 void *setup_data, size_t setup_size, void *data, size_t size, 336 338 usbhc_iface_transfer_in_callback_t callback, void *arg) 337 339 { 338 340 assert(fun); 339 hc_t *hc = fun_to_hc(fun); 340 assert(hc); 341 usb_speed_t speed = 342 usb_device_keeper_get_speed(&hc->manager, target.address); 341 uhci_hc_t *hc = fun_to_uhci_hc(fun); 342 assert(hc); 343 usb_speed_t speed = usb_device_keeper_get_speed(&hc->device_manager, target.address); 343 344 344 345 usb_log_debug("Control READ(%d) %d:%d %zu(%zu).\n", 345 346 speed, target.address, target.endpoint, size, max_packet_size); 346 usb_transfer_batch_t *batch = 347 batch_get(fun, target, USB_TRANSFER_CONTROL, max_packet_size, speed, 348 data, size, setup_data, setup_size, callback, NULL, arg, 349 &hc->manager); 347 usb_transfer_batch_t *batch = batch_get(fun, target, USB_TRANSFER_CONTROL, 348 max_packet_size, speed, data, size, setup_data, setup_size, callback, 349 NULL, arg, &hc->device_manager); 350 350 if (!batch) 351 351 return ENOMEM; 352 352 batch_control_read(batch); 353 const int ret = hc_schedule(hc, batch); 354 if (ret != EOK) { 355 batch_dispose(batch); 356 } 357 return ret; 358 } 359 /*----------------------------------------------------------------------------*/ 360 usbhc_iface_t hc_iface = { 353 const int ret = uhci_hc_schedule(hc, batch); 354 if (ret != EOK) { 355 batch_dispose(batch); 356 return ret; 357 } 358 return EOK; 359 } 360 /*----------------------------------------------------------------------------*/ 361 usbhc_iface_t uhci_hc_iface = { 361 362 .reserve_default_address = reserve_default_address, 362 363 .release_default_address = release_default_address, … … 368 369 .interrupt_in = interrupt_in, 369 370 371 .bulk_in = bulk_in, 370 372 .bulk_out = bulk_out, 371 .bulk_in = bulk_in, 372 373 374 .control_read = control_read, 373 375 .control_write = control_write, 374 .control_read = control_read,375 376 }; 376 377 /** -
uspace/drv/uhci-hcd/iface.h
r50114ef r5f80527 38 38 #include <usbhc_iface.h> 39 39 40 extern usbhc_iface_t hc_iface;40 extern usbhc_iface_t uhci_hc_iface; 41 41 42 42 #endif -
uspace/drv/uhci-hcd/transfer_list.c
r50114ef r5f80527 79 79 if (!instance->queue_head) 80 80 return; 81 /* Set both queue_head.next to point to the follower*/81 /* Set both next and element to point to the same QH */ 82 82 qh_set_next_qh(instance->queue_head, next->queue_head_pa); 83 qh_set_element_qh(instance->queue_head, next->queue_head_pa); 83 84 } 84 85 /*----------------------------------------------------------------------------*/ … … 91 92 * The batch is added to the end of the list and queue. 92 93 */ 93 void transfer_list_add_batch( 94 transfer_list_t *instance, usb_transfer_batch_t *batch) 94 void transfer_list_add_batch(transfer_list_t *instance, usb_transfer_batch_t *batch) 95 95 { 96 96 assert(instance); … … 98 98 usb_log_debug2("Queue %s: Adding batch(%p).\n", instance->name, batch); 99 99 100 const uint32_t pa = addr_to_phys(batch_qh(batch)); 101 assert((pa & LINK_POINTER_ADDRESS_MASK) == pa); 102 103 /* New batch will be added to the end of the current list 104 * so set the link accordingly */ 105 qh_set_next_qh(batch_qh(batch), instance->queue_head->next); 106 100 107 fibril_mutex_lock(&instance->guard); 101 108 102 qh_t *last_qh = NULL;103 109 /* Add to the hardware queue. */ 104 110 if (list_empty(&instance->batch_list)) { 105 111 /* There is nothing scheduled */ 106 last_qh = instance->queue_head; 112 qh_t *qh = instance->queue_head; 113 assert(qh->element == qh->next); 114 qh_set_element_qh(qh, pa); 107 115 } else { 108 116 /* There is something scheduled */ 109 117 usb_transfer_batch_t *last = list_get_instance( 110 118 instance->batch_list.prev, usb_transfer_batch_t, link); 111 last_qh = batch_qh(last); 112 } 113 const uint32_t pa = addr_to_phys(batch_qh(batch)); 114 assert((pa & LINK_POINTER_ADDRESS_MASK) == pa); 115 116 /* keep link */ 117 batch_qh(batch)->next = last_qh->next; 118 qh_set_next_qh(last_qh, pa); 119 119 qh_set_next_qh(batch_qh(last), pa); 120 } 120 121 /* Add to the driver list */ 121 122 list_append(&batch->link, &instance->batch_list); … … 147 148 while (current != &instance->batch_list) { 148 149 link_t *next = current->next; 149 usb_transfer_batch_t *batch = 150 list_get_instance(current, usb_transfer_batch_t, link); 150 usb_transfer_batch_t *batch = list_get_instance(current, usb_transfer_batch_t, link); 151 151 152 152 if (batch_is_complete(batch)) { … … 162 162 link_t *item = done.next; 163 163 list_remove(item); 164 usb_transfer_batch_t *batch = 165 list_get_instance(item, usb_transfer_batch_t, link); 164 usb_transfer_batch_t *batch = list_get_instance(item, usb_transfer_batch_t, link); 166 165 batch->next_step(batch); 167 166 } … … 175 174 { 176 175 fibril_mutex_lock(&instance->guard); 177 while ( !list_empty(&instance->batch_list)) {176 while (list_empty(&instance->batch_list)) { 178 177 link_t *current = instance->batch_list.next; 179 usb_transfer_batch_t *batch = 180 list_get_instance(current, usb_transfer_batch_t, link); 178 usb_transfer_batch_t *batch = list_get_instance(current, usb_transfer_batch_t, link); 181 179 transfer_list_remove_batch(instance, batch); 182 180 usb_transfer_batch_finish(batch, EIO); … … 193 191 * Does not lock the transfer list, caller is responsible for that. 194 192 */ 195 void transfer_list_remove_batch( 196 transfer_list_t *instance, usb_transfer_batch_t *batch) 193 void transfer_list_remove_batch(transfer_list_t *instance, usb_transfer_batch_t *batch) 197 194 { 198 195 assert(instance); … … 200 197 assert(batch); 201 198 assert(batch_qh(batch)); 202 assert(fibril_mutex_is_locked(&instance->guard));203 204 199 usb_log_debug2( 205 200 "Queue %s: removing batch(%p).\n", instance->name, batch); 206 201 207 const char * qpos = NULL;202 const char * pos = NULL; 208 203 /* Remove from the hardware queue */ 209 if ( instance->batch_list.next == &batch->link) {204 if (batch->link.prev == &instance->batch_list) { 210 205 /* I'm the first one here */ 211 assert((instance->queue_head->next & LINK_POINTER_ADDRESS_MASK) 212 == addr_to_phys(batch_qh(batch))); 213 instance->queue_head->next = batch_qh(batch)->next; 214 qpos = "FIRST"; 206 qh_set_element_qh(instance->queue_head, batch_qh(batch)->next); 207 pos = "FIRST"; 215 208 } else { 216 209 usb_transfer_batch_t *prev = 217 list_get_instance( 218 batch->link.prev, usb_transfer_batch_t, link); 219 assert((batch_qh(prev)->next & LINK_POINTER_ADDRESS_MASK) 220 == addr_to_phys(batch_qh(batch))); 221 batch_qh(prev)->next = batch_qh(batch)->next; 222 qpos = "NOT FIRST"; 223 } 224 /* Remove from the batch list */ 210 list_get_instance(batch->link.prev, usb_transfer_batch_t, link); 211 qh_set_next_qh(batch_qh(prev), batch_qh(batch)->next); 212 pos = "NOT FIRST"; 213 } 214 /* Remove from the driver list */ 225 215 list_remove(&batch->link); 226 usb_log_debug("Batch(%p) removed (%s) from %s, next %x.\n",227 batch, qpos, instance->name, batch_qh(batch)->next);216 usb_log_debug("Batch(%p) removed (%s) from %s, next element %x.\n", 217 batch, pos, instance->name, batch_qh(batch)->next); 228 218 } 229 219 /** -
uspace/drv/uhci-hcd/transfer_list.h
r50114ef r5f80527 37 37 #include <fibril_synch.h> 38 38 39 #include "uhci_struct/queue_head.h" 40 39 41 #include "batch.h" 40 #include "hw_struct/queue_head.h"41 42 42 43 typedef struct transfer_list -
uspace/drv/uhci-hcd/uhci.c
r50114ef r5f80527 54 54 { 55 55 assert(dev); 56 hc_t *hc = &((uhci_t*)dev->driver_data)->hc;56 uhci_hc_t *hc = &((uhci_t*)dev->driver_data)->hc; 57 57 uint16_t status = IPC_GET_ARG1(*call); 58 58 assert(hc); 59 hc_interrupt(hc, status);59 uhci_hc_interrupt(hc, status); 60 60 } 61 61 /*----------------------------------------------------------------------------*/ … … 70 70 { 71 71 assert(fun); 72 usb_device_keeper_t *manager = &((uhci_t*)fun->dev->driver_data)->hc. manager;72 usb_device_keeper_t *manager = &((uhci_t*)fun->dev->driver_data)->hc.device_manager; 73 73 74 74 usb_address_t addr = usb_device_keeper_find(manager, handle); … … 107 107 }; 108 108 /*----------------------------------------------------------------------------*/ 109 static ddf_dev_ops_t hc_ops = {109 static ddf_dev_ops_t uhci_hc_ops = { 110 110 .interfaces[USB_DEV_IFACE] = &usb_iface, 111 .interfaces[USBHC_DEV_IFACE] = & hc_iface, /* see iface.h/c */111 .interfaces[USBHC_DEV_IFACE] = &uhci_hc_iface, /* see iface.h/c */ 112 112 }; 113 113 /*----------------------------------------------------------------------------*/ … … 120 120 { 121 121 assert(fun); 122 return &(( rh_t*)fun->driver_data)->resource_list;122 return &((uhci_rh_t*)fun->driver_data)->resource_list; 123 123 } 124 124 /*----------------------------------------------------------------------------*/ … … 128 128 }; 129 129 /*----------------------------------------------------------------------------*/ 130 static ddf_dev_ops_t rh_ops = {130 static ddf_dev_ops_t uhci_rh_ops = { 131 131 .interfaces[USB_DEV_IFACE] = &usb_iface, 132 132 .interfaces[HW_RES_DEV_IFACE] = &hw_res_iface … … 175 175 176 176 bool interrupts = false; 177 #ifdef CONFIG_USBHC_NO_INTERRUPTS178 usb_log_warning("Interrupts disabled in OS config, " \179 "falling back to polling.\n");180 #else181 177 ret = pci_enable_interrupts(device); 182 178 if (ret != EOK) { 183 usb_log_warning("Failed to enable interrupts: %s.\n", 184 str_error(ret)); 185 usb_log_info("HW interrupts not available, " \ 186 "falling back to polling.\n"); 179 usb_log_warning( 180 "Failed(%d) to enable interrupts, fall back to polling.\n", 181 ret); 187 182 } else { 188 183 usb_log_debug("Hw interrupts enabled.\n"); 189 184 interrupts = true; 190 185 } 191 #endif192 186 193 187 instance->hc_fun = ddf_fun_create(device, fun_exposed, "uhci-hc"); … … 196 190 "Failed(%d) to create HC function.\n", ret); 197 191 198 ret = hc_init(&instance->hc, instance->hc_fun,192 ret = uhci_hc_init(&instance->hc, instance->hc_fun, 199 193 (void*)io_reg_base, io_reg_size, interrupts); 200 194 CHECK_RET_DEST_FUN_RETURN(ret, "Failed(%d) to init uhci-hcd.\n", ret); 201 instance->hc_fun->ops = & hc_ops;195 instance->hc_fun->ops = &uhci_hc_ops; 202 196 instance->hc_fun->driver_data = &instance->hc; 203 197 ret = ddf_fun_bind(instance->hc_fun); … … 214 208 if (instance->rh_fun) \ 215 209 ddf_fun_destroy(instance->rh_fun); \ 216 hc_fini(&instance->hc); \210 uhci_hc_fini(&instance->hc); \ 217 211 return ret; \ 218 212 } … … 229 223 "Failed(%d) to create root hub function.\n", ret); 230 224 231 ret = rh_init(&instance->rh, instance->rh_fun,225 ret = uhci_rh_init(&instance->rh, instance->rh_fun, 232 226 (uintptr_t)instance->hc.registers + 0x10, 4); 233 227 CHECK_RET_FINI_RETURN(ret, 234 228 "Failed(%d) to setup UHCI root hub.\n", ret); 235 229 236 instance->rh_fun->ops = & rh_ops;230 instance->rh_fun->ops = &uhci_rh_ops; 237 231 instance->rh_fun->driver_data = &instance->rh; 238 232 ret = ddf_fun_bind(instance->rh_fun); -
uspace/drv/uhci-hcd/uhci.h
r50114ef r5f80527 38 38 #include <ddf/driver.h> 39 39 40 #include " hc.h"41 #include " root_hub.h"40 #include "uhci_hc.h" 41 #include "uhci_rh.h" 42 42 43 43 typedef struct uhci { … … 45 45 ddf_fun_t *rh_fun; 46 46 47 hc_t hc;48 rh_t rh;47 uhci_hc_t hc; 48 uhci_rh_t rh; 49 49 } uhci_t; 50 50 -
uspace/drv/uhci-hcd/utils/malloc32.h
r50114ef r5f80527 50 50 static inline uintptr_t addr_to_phys(void *addr) 51 51 { 52 if (addr == NULL)53 return 0;54 55 52 uintptr_t result; 56 53 int ret = as_get_physical_mapping(addr, &result); -
uspace/lib/usb/src/host/device_keeper.c
r50114ef r5f80527 214 214 fibril_mutex_lock(&instance->guard); 215 215 216 usb_address_t new_address = instance->last_address; 217 do { 218 ++new_address; 219 if (new_address > USB11_ADDRESS_MAX) 220 new_address = 1; 216 usb_address_t new_address = instance->last_address + 1; 217 while (instance->devices[new_address].occupied) { 221 218 if (new_address == instance->last_address) { 222 219 fibril_mutex_unlock(&instance->guard); 223 220 return ENOSPC; 224 221 } 225 } while (instance->devices[new_address].occupied); 222 if (new_address == USB11_ADDRESS_MAX) 223 new_address = 1; 224 ++new_address; 225 } 226 226 227 227 assert(new_address != USB_ADDRESS_DEFAULT);
Note:
See TracChangeset
for help on using the changeset viewer.
