Changeset 55e388a1 in mainline for uspace/drv/uhci-hcd/hc.c
- Timestamp:
- 2011-03-24T14:57:53Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- b53d3b7
- Parents:
- 361e61b (diff), e18e0d6 (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. - File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/uhci-hcd/hc.c
r361e61b r55e388a1 42 42 #include <usb_iface.h> 43 43 44 #include " uhci_hc.h"44 #include "hc.h" 45 45 46 46 static irq_cmd_t uhci_cmds[] = { … … 60 60 }; 61 61 /*----------------------------------------------------------------------------*/ 62 static int uhci_hc_init_transfer_lists(uhci_hc_t *instance);63 static int uhci_hc_init_mem_structures(uhci_hc_t *instance);64 static void uhci_hc_init_hw(uhci_hc_t *instance);65 66 static int uhci_hc_interrupt_emulator(void *arg);67 static int uhci_hc_debug_checker(void *arg);68 69 static bool allowed_usb_packet(62 static int hc_init_transfer_lists(hc_t *instance); 63 static int hc_init_mem_structures(hc_t *instance); 64 static void hc_init_hw(hc_t *instance); 65 66 static int hc_interrupt_emulator(void *arg); 67 static int hc_debug_checker(void *arg); 68 69 static bool usb_is_allowed( 70 70 bool low_speed, usb_transfer_type_t transfer, size_t size); 71 71 /*----------------------------------------------------------------------------*/ … … 82 82 * interrupt fibrils. 83 83 */ 84 int uhci_hc_init(uhci_hc_t *instance, ddf_fun_t *fun,84 int hc_init(hc_t *instance, ddf_fun_t *fun, 85 85 void *regs, size_t reg_size, bool interrupts) 86 86 { … … 112 112 io, reg_size); 113 113 114 ret = uhci_hc_init_mem_structures(instance);114 ret = hc_init_mem_structures(instance); 115 115 CHECK_RET_DEST_FUN_RETURN(ret, 116 116 "Failed to initialize UHCI memory structures.\n"); 117 117 118 uhci_hc_init_hw(instance);118 hc_init_hw(instance); 119 119 if (!interrupts) { 120 120 instance->cleaner = 121 fibril_create( uhci_hc_interrupt_emulator, instance);121 fibril_create(hc_interrupt_emulator, instance); 122 122 fibril_add_ready(instance->cleaner); 123 } 124 125 instance->debug_checker = fibril_create(uhci_hc_debug_checker, instance); 126 fibril_add_ready(instance->debug_checker); 127 128 usb_log_info("Started UHCI driver.\n"); 123 } else { 124 /* TODO: enable interrupts here */ 125 } 126 127 instance->debug_checker = 128 fibril_create(hc_debug_checker, instance); 129 // fibril_add_ready(instance->debug_checker); 130 129 131 return EOK; 130 132 #undef CHECK_RET_DEST_FUN_RETURN … … 136 138 * For magic values see UHCI Design Guide 137 139 */ 138 void uhci_hc_init_hw(uhci_hc_t *instance)140 void hc_init_hw(hc_t *instance) 139 141 { 140 142 assert(instance); … … 184 186 * - frame list page (needs to be one UHCI hw accessible 4K page) 185 187 */ 186 int uhci_hc_init_mem_structures(uhci_hc_t *instance)188 int hc_init_mem_structures(hc_t *instance) 187 189 { 188 190 assert(instance); … … 213 215 214 216 /* Init transfer lists */ 215 ret = uhci_hc_init_transfer_lists(instance);217 ret = hc_init_transfer_lists(instance); 216 218 CHECK_RET_DEST_CMDS_RETURN(ret, "Failed to init transfer lists.\n"); 217 219 usb_log_debug("Initialized transfer lists.\n"); … … 234 236 235 237 /* Init device keeper*/ 236 device_keeper_init(&instance->device_manager);238 usb_device_keeper_init(&instance->manager); 237 239 usb_log_debug("Initialized device manager.\n"); 238 240 … … 250 252 * USB scheduling. Sets pointer table for quick access. 251 253 */ 252 int uhci_hc_init_transfer_lists(uhci_hc_t *instance)254 int hc_init_transfer_lists(hc_t *instance) 253 255 { 254 256 assert(instance); … … 316 318 * Checks for bandwidth availability and appends the batch to the proper queue. 317 319 */ 318 int uhci_hc_schedule(uhci_hc_t *instance,batch_t *batch)320 int hc_schedule(hc_t *instance, usb_transfer_batch_t *batch) 319 321 { 320 322 assert(instance); 321 323 assert(batch); 322 324 const int low_speed = (batch->speed == USB_SPEED_LOW); 323 if (! allowed_usb_packet(325 if (!usb_is_allowed( 324 326 low_speed, batch->transfer_type, batch->max_packet_size)) { 325 327 usb_log_warning( 326 "Invalid USB packetspecified %s SPEED %d %zu.\n",328 "Invalid USB transfer specified %s SPEED %d %zu.\n", 327 329 low_speed ? "LOW" : "FULL" , batch->transfer_type, 328 330 batch->max_packet_size); … … 349 351 * - resume from suspend state (not implemented) 350 352 */ 351 void uhci_hc_interrupt(uhci_hc_t *instance, uint16_t status)353 void hc_interrupt(hc_t *instance, uint16_t status) 352 354 { 353 355 assert(instance); … … 371 373 if (instance->hw_failures < UHCI_ALLOWED_HW_FAIL) { 372 374 /* reinitialize hw, this triggers virtual disconnect*/ 373 uhci_hc_init_hw(instance);375 hc_init_hw(instance); 374 376 } else { 375 377 usb_log_fatal("Too many UHCI hardware failures!.\n"); 376 uhci_hc_fini(instance);378 hc_fini(instance); 377 379 } 378 380 } … … 384 386 * @return EOK (should never return) 385 387 */ 386 int uhci_hc_interrupt_emulator(void* arg)388 int hc_interrupt_emulator(void* arg) 387 389 { 388 390 usb_log_debug("Started interrupt emulator.\n"); 389 uhci_hc_t *instance = (uhci_hc_t*)arg;391 hc_t *instance = (hc_t*)arg; 390 392 assert(instance); 391 393 … … 396 398 if (status != 0) 397 399 usb_log_debug2("UHCI status: %x.\n", status); 398 uhci_hc_interrupt(instance, status);400 hc_interrupt(instance, status); 399 401 async_usleep(UHCI_CLEANER_TIMEOUT); 400 402 } … … 407 409 * @return EOK (should never return) 408 410 */ 409 int uhci_hc_debug_checker(void *arg)410 { 411 uhci_hc_t *instance = (uhci_hc_t*)arg;411 int hc_debug_checker(void *arg) 412 { 413 hc_t *instance = (hc_t*)arg; 412 414 assert(instance); 413 415 … … 469 471 } 470 472 /*----------------------------------------------------------------------------*/ 471 /** Check transfer packets,for USB validity473 /** Check transfers for USB validity 472 474 * 473 475 * @param[in] low_speed Transfer speed. 474 476 * @param[in] transfer Transer type 475 * @param[in] size Maximum size of usedpackets477 * @param[in] size Size of data packets 476 478 * @return True if transaction is allowed by USB specs, false otherwise 477 479 */ 478 bool allowed_usb_packet(480 bool usb_is_allowed( 479 481 bool low_speed, usb_transfer_type_t transfer, size_t size) 480 482 {
Note:
See TracChangeset
for help on using the changeset viewer.