Changeset dcaf819 in mainline for uspace/drv
- Timestamp:
- 2011-04-06T22:33:08Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 9a7e5b4
- Parents:
- 6bf9bc4 (diff), 87305bb (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/drv
- Files:
-
- 3 added
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/ohci/batch.c
r6bf9bc4 rdcaf819 73 73 CHECK_NULL_DISPOSE_RETURN(instance, 74 74 "Failed to allocate batch instance.\n"); 75 usb_transfer_batch_init(instance, target, transfer_type, speed, max_packet_size,76 buffer, NULL, buffer_size, NULL, setup_size, func_in,77 func_ out, arg, fun, NULL);75 usb_transfer_batch_init(instance, target, transfer_type, speed, 76 max_packet_size, buffer, NULL, buffer_size, NULL, setup_size, 77 func_in, func_out, arg, fun, NULL, NULL); 78 78 79 79 if (buffer_size > 0) { -
uspace/drv/ohci/hc.c
r6bf9bc4 rdcaf819 92 92 instance->ddf_instance = fun; 93 93 usb_device_keeper_init(&instance->manager); 94 ret = bandwidth_init(&instance->bandwidth, BANDWIDTH_AVAILABLE_USB11,95 bandwidth_count_usb11);96 CHECK_RET_RETURN(ret, "Failed to initialize bandwidth allocator: %s.\n",94 ret = usb_endpoint_manager_init(&instance->ep_manager, 95 BANDWIDTH_AVAILABLE_USB11); 96 CHECK_RET_RETURN(ret, "Failed to initialize endpoint manager: %s.\n", 97 97 ret, str_error(ret)); 98 98 -
uspace/drv/ohci/hc.h
r6bf9bc4 rdcaf819 42 42 #include <usb/usb.h> 43 43 #include <usb/host/device_keeper.h> 44 #include <usb/host/ bandwidth.h>44 #include <usb/host/usb_endpoint_manager.h> 45 45 #include <usbhc_iface.h> 46 46 … … 55 55 ddf_fun_t *ddf_instance; 56 56 usb_device_keeper_t manager; 57 bandwidth_t bandwidth;57 usb_endpoint_manager_t ep_manager; 58 58 fid_t interrupt_emulator; 59 59 } hc_t; -
uspace/drv/ohci/iface.c
r6bf9bc4 rdcaf819 162 162 address, endpoint, usb_str_transfer_type(transfer_type), 163 163 usb_str_speed(speed), direction, size, max_packet_size, interval); 164 return bandwidth_reserve(&hc->bandwidth, address, endpoint, direction, 165 speed, transfer_type, max_packet_size, size, interval); 164 // TODO use real endpoint here! 165 return usb_endpoint_manager_register_ep(&hc->ep_manager, 166 address, endpoint, direction, NULL, 0); 166 167 } 167 168 /*----------------------------------------------------------------------------*/ … … 183 184 usb_log_debug("Unregister endpoint %d:%d %d.\n", 184 185 address, endpoint, direction); 185 return bandwidth_release(&hc->bandwidth, address, endpoint, direction); 186 187 return ENOTSUP; 186 return usb_endpoint_manager_unregister_ep(&hc->ep_manager, address, 187 endpoint, direction); 188 188 } 189 189 /*----------------------------------------------------------------------------*/ -
uspace/drv/uhci-hcd/batch.c
r6bf9bc4 rdcaf819 49 49 td_t *tds; 50 50 size_t transfers; 51 usb_device_keeper_t *manager;52 51 } uhci_batch_t; 53 52 … … 73 72 * @param[in] func_out function to call on outbound transaction completion 74 73 * @param[in] arg additional parameter to func_in or func_out 75 * @param[in] manager Pointer totoggle management structure.74 * @param[in] ep Pointer to endpoint toggle management structure. 76 75 * @return Valid pointer if all substructures were successfully created, 77 76 * NULL otherwise. … … 86 85 char* setup_buffer, size_t setup_size, 87 86 usbhc_iface_transfer_in_callback_t func_in, 88 usbhc_iface_transfer_out_callback_t func_out, void *arg, 89 usb_device_keeper_t *manager 87 usbhc_iface_transfer_out_callback_t func_out, void *arg, endpoint_t *ep 90 88 ) 91 89 { … … 105 103 CHECK_NULL_DISPOSE_RETURN(instance, 106 104 "Failed to allocate batch instance.\n"); 107 usb_transfer_batch_init(instance, target, transfer_type, speed, max_packet_size, 105 usb_transfer_batch_init(instance, target, 106 transfer_type, speed, max_packet_size, 108 107 buffer, NULL, buffer_size, NULL, setup_size, func_in, 109 func_out, arg, fun, NULL);108 func_out, arg, fun, ep, NULL); 110 109 111 110 … … 114 113 "Failed to allocate batch instance.\n"); 115 114 bzero(data, sizeof(uhci_batch_t)); 116 data->manager = manager;117 115 instance->private_data = data; 118 116 … … 180 178 instance, i, data->tds[i].status); 181 179 td_print_status(&data->tds[i]); 182 183 usb_device_keeper_set_toggle(data->manager, 184 instance->target, instance->direction, 185 td_toggle(&data->tds[i])); 180 if (instance->ep != NULL) 181 endpoint_toggle_set(instance->ep, 182 td_toggle(&data->tds[i])); 186 183 if (i > 0) 187 184 goto substract_ret; … … 310 307 311 308 const bool low_speed = instance->speed == USB_SPEED_LOW; 312 int toggle = usb_device_keeper_get_toggle( 313 data->manager, instance->target, instance->direction); 309 int toggle = endpoint_toggle_get(instance->ep); 314 310 assert(toggle == 0 || toggle == 1); 315 311 … … 342 338 } 343 339 td_set_ioc(&data->tds[transfer - 1]); 344 usb_device_keeper_set_toggle(data->manager, instance->target, 345 instance->direction, toggle); 340 endpoint_toggle_set(instance->ep, toggle); 346 341 } 347 342 /*----------------------------------------------------------------------------*/ -
uspace/drv/uhci-hcd/batch.h
r6bf9bc4 rdcaf819 35 35 #define DRV_UHCI_BATCH_H 36 36 37 #include <adt/list.h>38 39 37 #include <usbhc_iface.h> 40 38 #include <usb/usb.h> 41 39 #include <usb/host/device_keeper.h> 40 #include <usb/host/endpoint.h> 42 41 #include <usb/host/batch.h> 43 42 … … 57 56 usbhc_iface_transfer_out_callback_t func_out, 58 57 void *arg, 59 usb_device_keeper_t *manager58 endpoint_t *ep 60 59 ); 61 60 -
uspace/drv/uhci-hcd/hc.c
r6bf9bc4 rdcaf819 66 66 static int hc_interrupt_emulator(void *arg); 67 67 static int hc_debug_checker(void *arg); 68 68 #if 0 69 69 static bool usb_is_allowed( 70 70 bool low_speed, usb_transfer_type_t transfer, size_t size); 71 #endif 71 72 /*----------------------------------------------------------------------------*/ 72 73 /** Initialize UHCI hcd driver structure … … 239 240 usb_log_debug("Initialized device manager.\n"); 240 241 241 ret = bandwidth_init(&instance->bandwidth, BANDWIDTH_AVAILABLE_USB11, 242 bandwidth_count_usb11); 242 ret = 243 usb_endpoint_manager_init(&instance->ep_manager, 244 BANDWIDTH_AVAILABLE_USB11); 243 245 assert(ret == EOK); 244 246 … … 326 328 assert(instance); 327 329 assert(batch); 328 const int low_speed = (batch->speed == USB_SPEED_LOW);329 if (!usb_is_allowed(330 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,333 batch->max_packet_size);334 return ENOTSUP;335 }336 /* Check available bandwidth */337 if (batch->transfer_type == USB_TRANSFER_INTERRUPT ||338 batch->transfer_type == USB_TRANSFER_ISOCHRONOUS) {339 size_t bw = bandwidth_count_usb11(batch->speed,340 batch->transfer_type, batch->buffer_size,341 batch->max_packet_size);342 int ret =343 bandwidth_use(&instance->bandwidth, batch->target.address,344 batch->target.endpoint, batch->direction, bw);345 if (ret != EOK) {346 usb_log_error("Failed(%d) to use reserved bw: %s.\n",347 ret, str_error(ret));348 return ret;349 }350 }351 330 352 331 transfer_list_t *list = … … 402 381 case USB_TRANSFER_INTERRUPT: 403 382 case USB_TRANSFER_ISOCHRONOUS: { 383 /* 404 384 int ret = bandwidth_free(&instance->bandwidth, 405 385 batch->target.address, … … 410 390 "reserved bw: %s.\n", ret, 411 391 str_error(ret)); 392 */ 412 393 } 413 394 default: … … 533 514 * @return True if transaction is allowed by USB specs, false otherwise 534 515 */ 516 #if 0 535 517 bool usb_is_allowed( 536 518 bool low_speed, usb_transfer_type_t transfer, size_t size) … … 550 532 return false; 551 533 } 534 #endif 552 535 /** 553 536 * @} -
uspace/drv/uhci-hcd/hc.h
r6bf9bc4 rdcaf819 43 43 #include <usbhc_iface.h> 44 44 #include <usb/host/device_keeper.h> 45 #include <usb/host/ bandwidth.h>45 #include <usb/host/usb_endpoint_manager.h> 46 46 47 47 #include "batch.h" … … 85 85 typedef struct hc { 86 86 usb_device_keeper_t manager; 87 bandwidth_t bandwidth;87 usb_endpoint_manager_t ep_manager; 88 88 89 89 regs_t *registers; -
uspace/drv/uhci-hcd/hw_struct/queue_head.h
r6bf9bc4 rdcaf819 39 39 40 40 #include "link_pointer.h" 41 #include "utils/malloc32.h"42 41 43 42 typedef struct queue_head { -
uspace/drv/uhci-hcd/iface.c
r6bf9bc4 rdcaf819 36 36 37 37 #include <usb/debug.h> 38 #include <usb/host/endpoint.h> 38 39 39 40 #include "iface.h" … … 54 55 usb_device_keeper_reserve_default_address(&hc->manager, speed); 55 56 return EOK; 57 #if 0 58 endpoint_t *ep = malloc(sizeof(endpoint_t)); 59 if (ep == NULL) 60 return ENOMEM; 61 const size_t max_packet_size = speed == USB_SPEED_LOW ? 8 : 64; 62 endpoint_init(ep, USB_TRANSFER_CONTROL, speed, max_packet_size); 63 int ret; 64 try_retgister: 65 ret = usb_endpoint_manager_register_ep(&hc->ep_manager, 66 USB_ADDRESS_DEFAULT, 0, USB_DIRECTION_BOTH, ep, endpoint_destroy, 0); 67 if (ret == EEXISTS) { 68 async_usleep(1000); 69 goto try_retgister; 70 } 71 if (ret != EOK) { 72 endpoint_destroy(ep); 73 } 74 return ret; 75 #endif 56 76 } 57 77 /*----------------------------------------------------------------------------*/ … … 67 87 assert(hc); 68 88 usb_log_debug("Default address release.\n"); 89 // return usb_endpoint_manager_unregister_ep(&hc->ep_manager, 90 // USB_ADDRESS_DEFAULT, 0, USB_DIRECTION_BOTH); 69 91 usb_device_keeper_release_default_address(&hc->manager); 70 92 return EOK; … … 137 159 const usb_speed_t speed = 138 160 usb_device_keeper_get_speed(&hc->manager, address); 139 size_t size = max_packet_size; 161 const size_t size = 162 (transfer_type == USB_TRANSFER_INTERRUPT 163 || transfer_type == USB_TRANSFER_ISOCHRONOUS) ? 164 max_packet_size : 0; 165 int ret; 166 167 endpoint_t *ep = malloc(sizeof(endpoint_t)); 168 if (ep == NULL) 169 return ENOMEM; 170 ret = endpoint_init(ep, transfer_type, speed, max_packet_size); 171 if (ret != EOK) { 172 free(ep); 173 return ret; 174 } 140 175 141 176 usb_log_debug("Register endpoint %d:%d %s %s(%d) %zu(%zu) %u.\n", 142 177 address, endpoint, usb_str_transfer_type(transfer_type), 143 178 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); 179 180 ret = usb_endpoint_manager_register_ep(&hc->ep_manager, 181 address, endpoint, direction, ep, size); 182 if (ret != EOK) { 183 endpoint_destroy(ep); 184 } else { 185 usb_device_keeper_add_ep(&hc->manager, address, ep); 186 } 187 return ret; 146 188 } 147 189 /*----------------------------------------------------------------------------*/ … … 154 196 usb_log_debug("Unregister endpoint %d:%d %d.\n", 155 197 address, endpoint, direction); 156 return bandwidth_release(&hc->bandwidth, address, endpoint, direction); 198 return usb_endpoint_manager_unregister_ep(&hc->ep_manager, address, 199 endpoint, direction); 157 200 } 158 201 /*----------------------------------------------------------------------------*/ … … 175 218 hc_t *hc = fun_to_hc(fun); 176 219 assert(hc); 177 usb_speed_t speed =178 usb_device_keeper_get_speed(&hc->manager, target.address);179 220 180 221 usb_log_debug("Interrupt OUT %d:%d %zu(%zu).\n", 181 222 target.address, target.endpoint, size, max_packet_size); 182 223 224 size_t res_bw; 225 endpoint_t *ep = usb_endpoint_manager_get_ep(&hc->ep_manager, 226 target.address, target.endpoint, USB_DIRECTION_OUT, &res_bw); 227 if (ep == NULL) { 228 usb_log_error("Endpoint(%d:%d) not registered for INT OUT.\n", 229 target.address, target.endpoint); 230 return ENOENT; 231 } 232 const size_t bw = bandwidth_count_usb11(ep->speed, ep->transfer_type, 233 size, ep->max_packet_size); 234 if (res_bw < bw) 235 { 236 usb_log_error("Endpoint(%d:%d) INT IN needs %zu bw " 237 "but only %zu is reserved.\n", 238 target.address, target.endpoint, bw, res_bw); 239 return ENOENT; 240 } 241 assert(ep->speed == 242 usb_device_keeper_get_speed(&hc->manager, target.address)); 243 assert(ep->max_packet_size == max_packet_size); 244 assert(ep->transfer_type == USB_TRANSFER_INTERRUPT); 245 183 246 usb_transfer_batch_t *batch = 184 batch_get(fun, target, USB_TRANSFER_INTERRUPT,max_packet_size,185 speed, data, size, NULL, 0, NULL, callback, arg, &hc->manager);247 batch_get(fun, target, ep->transfer_type, ep->max_packet_size, 248 ep->speed, data, size, NULL, 0, NULL, callback, arg, ep); 186 249 if (!batch) 187 250 return ENOMEM; … … 212 275 hc_t *hc = fun_to_hc(fun); 213 276 assert(hc); 214 usb_speed_t speed = 215 usb_device_keeper_get_speed(&hc->manager, target.address); 277 216 278 usb_log_debug("Interrupt IN %d:%d %zu(%zu).\n", 217 279 target.address, target.endpoint, size, max_packet_size); 218 280 281 size_t res_bw; 282 endpoint_t *ep = usb_endpoint_manager_get_ep(&hc->ep_manager, 283 target.address, target.endpoint, USB_DIRECTION_IN, &res_bw); 284 if (ep == NULL) { 285 usb_log_error("Endpoint(%d:%d) not registered for INT IN.\n", 286 target.address, target.endpoint); 287 return ENOENT; 288 } 289 const size_t bw = bandwidth_count_usb11(ep->speed, ep->transfer_type, 290 size, ep->max_packet_size); 291 if (res_bw < bw) 292 { 293 usb_log_error("Endpoint(%d:%d) INT IN needs %zu bw " 294 "but only %zu bw is reserved.\n", 295 target.address, target.endpoint, bw, res_bw); 296 return ENOENT; 297 } 298 299 assert(ep->speed == 300 usb_device_keeper_get_speed(&hc->manager, target.address)); 301 assert(ep->max_packet_size == max_packet_size); 302 assert(ep->transfer_type == USB_TRANSFER_INTERRUPT); 303 219 304 usb_transfer_batch_t *batch = 220 batch_get(fun, target, USB_TRANSFER_INTERRUPT,max_packet_size,221 speed, data, size, NULL, 0, callback, NULL, arg, &hc->manager);305 batch_get(fun, target, ep->transfer_type, ep->max_packet_size, 306 ep->speed, data, size, NULL, 0, callback, NULL, arg, ep); 222 307 if (!batch) 223 308 return ENOMEM; … … 248 333 hc_t *hc = fun_to_hc(fun); 249 334 assert(hc); 250 usb_speed_t speed =251 usb_device_keeper_get_speed(&hc->manager, target.address);252 335 253 336 usb_log_debug("Bulk OUT %d:%d %zu(%zu).\n", 254 337 target.address, target.endpoint, size, max_packet_size); 255 338 339 endpoint_t *ep = usb_endpoint_manager_get_ep(&hc->ep_manager, 340 target.address, target.endpoint, USB_DIRECTION_OUT, NULL); 341 if (ep == NULL) { 342 usb_log_error("Endpoint(%d:%d) not registered for BULK OUT.\n", 343 target.address, target.endpoint); 344 return ENOENT; 345 } 346 assert(ep->speed == 347 usb_device_keeper_get_speed(&hc->manager, target.address)); 348 assert(ep->max_packet_size == max_packet_size); 349 assert(ep->transfer_type == USB_TRANSFER_BULK); 350 256 351 usb_transfer_batch_t *batch = 257 batch_get(fun, target, USB_TRANSFER_BULK, max_packet_size, speed,258 data, size, NULL, 0, NULL, callback, arg, &hc->manager);352 batch_get(fun, target, ep->transfer_type, ep->max_packet_size, 353 ep->speed, data, size, NULL, 0, NULL, callback, arg, ep); 259 354 if (!batch) 260 355 return ENOMEM; … … 285 380 hc_t *hc = fun_to_hc(fun); 286 381 assert(hc); 287 usb_speed_t speed =288 usb_device_keeper_get_speed(&hc->manager, target.address);289 382 usb_log_debug("Bulk IN %d:%d %zu(%zu).\n", 290 383 target.address, target.endpoint, size, max_packet_size); 291 384 385 endpoint_t *ep = usb_endpoint_manager_get_ep(&hc->ep_manager, 386 target.address, target.endpoint, USB_DIRECTION_IN, NULL); 387 if (ep == NULL) { 388 usb_log_error("Endpoint(%d:%d) not registered for BULK IN.\n", 389 target.address, target.endpoint); 390 return ENOENT; 391 } 392 assert(ep->speed == 393 usb_device_keeper_get_speed(&hc->manager, target.address)); 394 assert(ep->max_packet_size == max_packet_size); 395 assert(ep->transfer_type == USB_TRANSFER_BULK); 396 292 397 usb_transfer_batch_t *batch = 293 batch_get(fun, target, USB_TRANSFER_BULK, max_packet_size, speed,294 data, size, NULL, 0, callback, NULL, arg, &hc->manager);398 batch_get(fun, target, ep->transfer_type, ep->max_packet_size, 399 ep->speed, data, size, NULL, 0, callback, NULL, arg, ep); 295 400 if (!batch) 296 401 return ENOMEM; … … 328 433 usb_log_debug("Control WRITE (%d) %d:%d %zu(%zu).\n", 329 434 speed, target.address, target.endpoint, size, max_packet_size); 435 endpoint_t *ep = usb_endpoint_manager_get_ep(&hc->ep_manager, 436 target.address, target.endpoint, USB_DIRECTION_BOTH, NULL); 437 if (ep == NULL) { 438 usb_log_warning("Endpoint(%d:%d) not registered for CONTROL.\n", 439 target.address, target.endpoint); 440 } 330 441 331 442 if (setup_size != 8) … … 334 445 usb_transfer_batch_t *batch = 335 446 batch_get(fun, target, USB_TRANSFER_CONTROL, max_packet_size, speed, 336 data, size, setup_data, setup_size, NULL, callback, arg, 337 &hc->manager); 447 data, size, setup_data, setup_size, NULL, callback, arg, ep); 338 448 if (!batch) 339 449 return ENOMEM; … … 373 483 usb_log_debug("Control READ(%d) %d:%d %zu(%zu).\n", 374 484 speed, target.address, target.endpoint, size, max_packet_size); 485 endpoint_t *ep = usb_endpoint_manager_get_ep(&hc->ep_manager, 486 target.address, target.endpoint, USB_DIRECTION_BOTH, NULL); 487 if (ep == NULL) { 488 usb_log_warning("Endpoint(%d:%d) not registered for CONTROL.\n", 489 target.address, target.endpoint); 490 } 375 491 usb_transfer_batch_t *batch = 376 492 batch_get(fun, target, USB_TRANSFER_CONTROL, max_packet_size, speed, 377 data, size, setup_data, setup_size, callback, NULL, arg, 378 &hc->manager); 493 data, size, setup_data, setup_size, callback, NULL, arg, ep); 379 494 if (!batch) 380 495 return ENOMEM; -
uspace/drv/uhci-hcd/transfer_list.h
r6bf9bc4 rdcaf819 39 39 #include "batch.h" 40 40 #include "hw_struct/queue_head.h" 41 #include "utils/malloc32.h" 41 42 42 43 typedef struct transfer_list -
uspace/drv/uhci-hcd/utils/malloc32.h
r6bf9bc4 rdcaf819 36 36 37 37 #include <assert.h> 38 #include <errno.h> 38 39 #include <malloc.h> 39 40 #include <mem.h>
Note:
See TracChangeset
for help on using the changeset viewer.