Changeset 1c6a45f in mainline
- Timestamp:
- 2011-03-21T23:12:15Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- b9fa0a9
- Parents:
- 62ed5bc
- Location:
- uspace/drv
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/ohci/iface.c
r62ed5bc r1c6a45f 33 33 */ 34 34 #include <ddf/driver.h> 35 #include <ddf/interrupt.h>36 #include <device/hw_res.h>37 35 #include <errno.h> 38 #include <str_error.h> 39 40 #include <usb_iface.h> 41 #include <usb/ddfiface.h> 36 42 37 #include <usb/debug.h> 43 38 … … 60 55 static int reserve_default_address(ddf_fun_t *fun, usb_speed_t speed) 61 56 { 62 63 64 65 66 67 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; 68 63 } 69 64 /*----------------------------------------------------------------------------*/ … … 75 70 static int release_default_address(ddf_fun_t *fun) 76 71 { 77 78 79 80 81 82 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; 83 78 } 84 79 /*----------------------------------------------------------------------------*/ … … 93 88 usb_address_t *address) 94 89 { 95 96 97 98 99 100 101 102 103 104 105 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; 106 101 } 107 102 /*----------------------------------------------------------------------------*/ … … 116 111 usb_address_t address, devman_handle_t handle) 117 112 { 118 119 120 121 122 123 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; 124 119 } 125 120 /*----------------------------------------------------------------------------*/ … … 132 127 static int release_address(ddf_fun_t *fun, usb_address_t address) 133 128 { 134 135 136 137 138 139 140 } 141 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 /*----------------------------------------------------------------------------*/ 142 137 /** Register endpoint for bandwidth reservation. 143 138 * … … 160 155 return ENOTSUP; 161 156 } 162 157 /*----------------------------------------------------------------------------*/ 163 158 /** Unregister endpoint (free some bandwidth reservation). 164 159 * … … 198 193 usbhc_iface_transfer_out_callback_t callback, void *arg) 199 194 { 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; 195 assert(fun); 196 hc_t *hc = fun_to_hc(fun); 197 assert(hc); 198 usb_speed_t speed = usb_device_keeper_get_speed(&hc->manager, target.address); 199 200 usb_log_debug("Interrupt OUT %d:%d %zu(%zu).\n", 201 target.address, target.endpoint, size, max_packet_size); 202 203 usb_transfer_batch_t *batch = batch_get(fun, target, USB_TRANSFER_INTERRUPT, 204 max_packet_size, speed, data, size, NULL, 0, NULL, callback, arg, 205 &hc->manager); 206 if (!batch) 207 return ENOMEM; 208 batch_interrupt_out(batch); 209 const int ret = hc_schedule(hc, batch); 210 if (ret != EOK) { 211 batch_dispose(batch); 212 return ret; 213 } 214 return EOK; 219 215 } 220 216 /*----------------------------------------------------------------------------*/ … … 240 236 usbhc_iface_transfer_in_callback_t callback, void *arg) 241 237 { 242 243 244 245 246 usb_log_debug("Interrupt IN %d:%d %zu(%zu).\n", 247 248 249 250 251 252 253 254 255 256 257 258 259 260 238 assert(fun); 239 hc_t *hc = fun_to_hc(fun); 240 assert(hc); 241 usb_speed_t speed = usb_device_keeper_get_speed(&hc->manager, target.address); 242 usb_log_debug("Interrupt IN %d:%d %zu(%zu).\n", 243 target.address, target.endpoint, size, max_packet_size); 244 245 usb_transfer_batch_t *batch = batch_get(fun, target, USB_TRANSFER_INTERRUPT, 246 max_packet_size, speed, data, size, NULL, 0, callback, NULL, arg, 247 &hc->manager); 248 if (!batch) 249 return ENOMEM; 250 batch_interrupt_in(batch); 251 const int ret = hc_schedule(hc, batch); 252 if (ret != EOK) { 253 batch_dispose(batch); 254 return ret; 255 } 256 return EOK; 261 257 } 262 258 /*----------------------------------------------------------------------------*/ … … 282 278 usbhc_iface_transfer_out_callback_t callback, void *arg) 283 279 { 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 280 assert(fun); 281 hc_t *hc = fun_to_hc(fun); 282 assert(hc); 283 usb_speed_t speed = usb_device_keeper_get_speed(&hc->manager, target.address); 284 285 usb_log_debug("Bulk OUT %d:%d %zu(%zu).\n", 286 target.address, target.endpoint, size, max_packet_size); 287 288 usb_transfer_batch_t *batch = batch_get(fun, target, USB_TRANSFER_BULK, 289 max_packet_size, speed, data, size, NULL, 0, NULL, callback, arg, 290 &hc->manager); 291 if (!batch) 292 return ENOMEM; 293 batch_bulk_out(batch); 294 const int ret = hc_schedule(hc, batch); 295 if (ret != EOK) { 296 batch_dispose(batch); 297 return ret; 298 } 299 return EOK; 305 300 } 306 301 /*----------------------------------------------------------------------------*/ … … 326 321 usbhc_iface_transfer_in_callback_t callback, void *arg) 327 322 { 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 323 assert(fun); 324 hc_t *hc = fun_to_hc(fun); 325 assert(hc); 326 usb_speed_t speed = usb_device_keeper_get_speed(&hc->manager, target.address); 327 usb_log_debug("Bulk IN %d:%d %zu(%zu).\n", 328 target.address, target.endpoint, size, max_packet_size); 329 330 usb_transfer_batch_t *batch = batch_get(fun, target, USB_TRANSFER_BULK, 331 max_packet_size, speed, data, size, NULL, 0, callback, NULL, arg, 332 &hc->manager); 333 if (!batch) 334 return ENOMEM; 335 batch_bulk_in(batch); 336 const int ret = hc_schedule(hc, batch); 337 if (ret != EOK) { 338 batch_dispose(batch); 339 return ret; 340 } 341 return EOK; 347 342 } 348 343 /*----------------------------------------------------------------------------*/ … … 369 364 static int control_write(ddf_fun_t *fun, usb_target_t target, 370 365 size_t max_packet_size, 371 void *setup_data, size_t setup_size, 372 void *data, size_t size, 366 void *setup_data, size_t setup_size, void *data, size_t size, 373 367 usbhc_iface_transfer_out_callback_t callback, void *arg) 374 368 { 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 369 assert(fun); 370 hc_t *hc = fun_to_hc(fun); 371 assert(hc); 372 usb_speed_t speed = usb_device_keeper_get_speed(&hc->manager, target.address); 373 usb_log_debug("Control WRITE (%d) %d:%d %zu(%zu).\n", 374 speed, target.address, target.endpoint, size, max_packet_size); 375 376 if (setup_size != 8) 377 return EINVAL; 378 379 usb_transfer_batch_t *batch = batch_get(fun, target, USB_TRANSFER_CONTROL, 380 max_packet_size, speed, data, size, setup_data, setup_size, 381 NULL, callback, arg, &hc->manager); 382 if (!batch) 383 return ENOMEM; 384 usb_device_keeper_reset_if_need(&hc->manager, target, setup_data); 385 batch_control_write(batch); 386 const int ret = hc_schedule(hc, batch); 387 if (ret != EOK) { 388 batch_dispose(batch); 389 return ret; 390 } 391 return EOK; 398 392 } 399 393 /*----------------------------------------------------------------------------*/ … … 420 414 static int control_read(ddf_fun_t *fun, usb_target_t target, 421 415 size_t max_packet_size, 422 void *setup_data, size_t setup_size, 423 void *data, size_t size, 416 void *setup_data, size_t setup_size, void *data, size_t size, 424 417 usbhc_iface_transfer_in_callback_t callback, void *arg) 425 418 { 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 419 assert(fun); 420 hc_t *hc = fun_to_hc(fun); 421 assert(hc); 422 usb_speed_t speed = usb_device_keeper_get_speed(&hc->manager, target.address); 423 424 usb_log_debug("Control READ(%d) %d:%d %zu(%zu).\n", 425 speed, target.address, target.endpoint, size, max_packet_size); 426 usb_transfer_batch_t *batch = batch_get(fun, target, USB_TRANSFER_CONTROL, 427 max_packet_size, speed, data, size, setup_data, setup_size, callback, 428 NULL, arg, &hc->manager); 429 if (!batch) 430 return ENOMEM; 431 batch_control_read(batch); 432 const int ret = hc_schedule(hc, batch); 433 if (ret != EOK) { 434 batch_dispose(batch); 435 return ret; 436 } 437 return EOK; 445 438 } 446 439 /*----------------------------------------------------------------------------*/ … … 463 456 464 457 .control_write = control_write, 465 .control_read = control_read 458 .control_read = control_read, 466 459 }; 467 460 -
uspace/drv/uhci-hcd/iface.c
r62ed5bc r1c6a45f 33 33 */ 34 34 #include <ddf/driver.h> 35 #include < remote_usbhc.h>35 #include <errno.h> 36 36 37 37 #include <usb/debug.h> 38 39 #include <errno.h>40 38 41 39 #include "iface.h" … … 48 46 * @return Error code. 49 47 */ 50 /*----------------------------------------------------------------------------*/51 48 static int reserve_default_address(ddf_fun_t *fun, usb_speed_t speed) 52 49 { … … 93 90 usb_log_debug("Address request with result: %d.\n", *address); 94 91 if (*address <= 0) 95 92 return *address; 96 93 return EOK; 97 94 } … … 192 189 usb_transfer_batch_t *batch = batch_get(fun, target, USB_TRANSFER_INTERRUPT, 193 190 max_packet_size, speed, data, size, NULL, 0, callback, NULL, arg, 194 191 &hc->manager); 195 192 if (!batch) 196 193 return ENOMEM; … … 369 366 .interrupt_in = interrupt_in, 370 367 368 .bulk_out = bulk_out, 371 369 .bulk_in = bulk_in, 372 .bulk_out = bulk_out, 373 370 371 .control_write = control_write, 374 372 .control_read = control_read, 375 .control_write = control_write,376 373 }; 377 374 /**
Note:
See TracChangeset
for help on using the changeset viewer.