Changes in / [98d7550:17fc40c] in mainline
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/ipc/irq.c
r98d7550 r17fc40c 370 370 if (AS != irq->driver_as) \ 371 371 as_switch(AS, irq->driver_as); \ 372 printf("Copying data from address: %p.\n", va); \ 372 373 memcpy_from_uspace(&target, va, (sizeof(target))); \ 373 374 if (dstarg) \ … … 380 381 if (AS != irq->driver_as) \ 381 382 as_switch(AS, irq->driver_as); \ 383 printf("Writing data to address: %p.\n", va); \ 382 384 memcpy_to_uspace(va, &val, sizeof(val)); \ 383 385 } while (0) … … 455 457 uint32_t val; 456 458 CMD_MEM_READ(val); 459 printf("mem READ value: %x.\n", val); 457 460 break; 458 461 } -
uspace/drv/ohci/batch.c
r98d7550 r17fc40c 100 100 */ 101 101 usb_transfer_batch_t * batch_get(ddf_fun_t *fun, endpoint_t *ep, 102 char *buffer, size_t buffer_size, 103 const char *setup_buffer, size_t setup_size, 102 char *buffer, size_t buffer_size, char* setup_buffer, size_t setup_size, 104 103 usbhc_iface_transfer_in_callback_t func_in, 105 104 usbhc_iface_transfer_out_callback_t func_out, void *arg) … … 121 120 ohci_transfer_batch_dispose); 122 121 123 consthcd_endpoint_t *hcd_ep = hcd_endpoint_get(ep);122 hcd_endpoint_t *hcd_ep = hcd_endpoint_get(ep); 124 123 assert(hcd_ep); 125 124 … … 130 129 data->td_count = 131 130 ((buffer_size + OHCI_TD_MAX_TRANSFER - 1) / OHCI_TD_MAX_TRANSFER); 132 /* Control transfer need Setup and Status stage */133 131 if (ep->transfer_type == USB_TRANSFER_CONTROL) { 134 132 data->td_count += 2; … … 409 407 char *buffer = instance->data_buffer; 410 408 while (remain_size > 0) { 411 const size_t transfer_size = remain_size > OHCI_TD_MAX_TRANSFER412 ?OHCI_TD_MAX_TRANSFER : remain_size;409 size_t transfer_size = remain_size > OHCI_TD_MAX_TRANSFER ? 410 OHCI_TD_MAX_TRANSFER : remain_size; 413 411 414 412 td_init(data->tds[td_current], instance->ep->direction, -
uspace/drv/ohci/batch.h
r98d7550 r17fc40c 43 43 usb_transfer_batch_t * batch_get( 44 44 ddf_fun_t *fun, endpoint_t *ep, char *buffer, size_t size, 45 c onst char *setup_buffer, size_t setup_size,45 char *setup_buffer, size_t setup_size, 46 46 usbhc_iface_transfer_in_callback_t func_in, 47 47 usbhc_iface_transfer_out_callback_t func_out, -
uspace/drv/ohci/endpoint_list.h
r98d7550 r17fc40c 42 42 43 43 /** Structure maintains both OHCI queue and software list of active endpoints.*/ 44 typedef struct endpoint_list { 44 typedef struct endpoint_list 45 { 45 46 /** Guard against add/remove races */ 46 47 fibril_mutex_t guard; … … 68 69 69 70 int endpoint_list_init(endpoint_list_t *instance, const char *name); 71 70 72 void endpoint_list_set_next(endpoint_list_t *instance, endpoint_list_t *next); 73 71 74 void endpoint_list_add_ep(endpoint_list_t *instance, hcd_endpoint_t *hcd_ep); 75 72 76 void endpoint_list_remove_ep(endpoint_list_t *instance, hcd_endpoint_t *hcd_ep); 73 77 #endif -
uspace/drv/ohci/hc.c
r98d7550 r17fc40c 51 51 static int hc_init_memory(hc_t *instance); 52 52 /*----------------------------------------------------------------------------*/ 53 /** Announce OHCI root hub to the DDF54 *55 * @param[in] instance OHCI driver intance56 * @param[in] hub_fun DDF fuction representing OHCI root hub57 * @return Error code58 */59 53 int hc_register_hub(hc_t *instance, ddf_fun_t *hub_fun) 60 54 { … … 62 56 assert(hub_fun); 63 57 64 const usb_address_t hub_address = 58 int ret; 59 60 usb_address_t hub_address = 65 61 device_keeper_get_free_address(&instance->manager, USB_SPEED_FULL); 66 62 if (hub_address <= 0) { 67 usb_log_error("Failed(%d) to get OHCI root hub address.\n", 68 hub_address); 63 usb_log_error("Failed to get OHCI root hub address.\n"); 69 64 return hub_address; 70 65 } … … 73 68 &instance->manager, hub_address, hub_fun->handle); 74 69 75 #define CHECK_RET_RELEASE(ret, message...) \ 76 if (ret != EOK) { \ 77 usb_log_error(message); \ 78 hc_remove_endpoint(instance, hub_address, 0, USB_DIRECTION_BOTH); \ 79 usb_device_keeper_release(&instance->manager, hub_address); \ 80 return ret; \ 81 } else (void)0 82 83 int ret = hc_add_endpoint(instance, hub_address, 0, USB_SPEED_FULL, 70 ret = hc_add_endpoint(instance, hub_address, 0, USB_SPEED_FULL, 84 71 USB_TRANSFER_CONTROL, USB_DIRECTION_BOTH, 64, 0, 0); 85 CHECK_RET_RELEASE(ret, "Failed(%d) to add OHCI rh endpoint 0.\n", ret); 72 if (ret != EOK) { 73 usb_log_error("Failed to add OHCI rh endpoint 0.\n"); 74 usb_device_keeper_release(&instance->manager, hub_address); 75 return ret; 76 } 86 77 87 78 char *match_str = NULL; 88 79 /* DDF needs heap allocated string */ 89 80 ret = asprintf(&match_str, "usb&class=hub"); 90 ret = ret > 0 ? 0 : ret; 91 CHECK_RET_RELEASE(ret, "Failed(%d) to create match-id string.\n", ret); 81 if (ret < 0) { 82 usb_log_error( 83 "Failed(%d) to create root hub match-id string.\n", ret); 84 usb_device_keeper_release(&instance->manager, hub_address); 85 return ret; 86 } 92 87 93 88 ret = ddf_fun_add_match_id(hub_fun, match_str, 100); 94 CHECK_RET_RELEASE(ret, "Failed(%d) add root hub match-id.\n", ret); 95 89 if (ret != EOK) { 90 usb_log_error("Failed add root hub match-id.\n"); 91 } 96 92 ret = ddf_fun_bind(hub_fun); 97 CHECK_RET_RELEASE(ret, "Failed(%d) to bind root hub function.\n", ret); 98 99 return EOK; 100 #undef CHECK_RET_RELEASE 101 } 102 /*----------------------------------------------------------------------------*/ 103 /** Initialize OHCI hc driver structure 104 * 105 * @param[in] instance Memory place for the structure. 106 * @param[in] regs Address of the memory mapped I/O registers. 107 * @param[in] reg_size Size of the memory mapped area. 108 * @param[in] interrupts True if w interrupts should be used 109 * @return Error code 110 */ 93 return ret; 94 } 95 /*----------------------------------------------------------------------------*/ 111 96 int hc_init(hc_t *instance, uintptr_t regs, size_t reg_size, bool interrupts) 112 97 { … … 136 121 #undef CHECK_RET_RETURN 137 122 123 124 // hc_init_hw(instance); 125 hc_gain_control(instance); 138 126 fibril_mutex_initialize(&instance->guard); 139 hc_gain_control(instance);140 127 141 128 rh_init(&instance->rh, instance->registers); … … 150 137 } 151 138 /*----------------------------------------------------------------------------*/ 152 /** Create end register endpoint structures153 *154 * @param[in] instance OHCI driver structure.155 * @param[in] address USB address of the device.156 * @param[in] endpoint USB endpoint number.157 * @param[in] speed Communication speeed of the device.158 * @param[in] type Endpoint's transfer type.159 * @param[in] direction Endpoint's direction.160 * @param[in] mps Maximum packet size the endpoint accepts.161 * @param[in] size Maximum allowed buffer size.162 * @param[in] interval Time between transfers(interrupt transfers only).163 * @return Error code164 */165 139 int hc_add_endpoint( 166 140 hc_t *instance, usb_address_t address, usb_endpoint_t endpoint, … … 220 194 } 221 195 /*----------------------------------------------------------------------------*/ 222 /** Dequeue and delete endpoint structures223 *224 * @param[in] instance OHCI hc driver structure.225 * @param[in] address USB address of the device.226 * @param[in] endpoint USB endpoint number.227 * @param[in] direction Direction of the endpoint.228 * @return Error code229 */230 196 int hc_remove_endpoint(hc_t *instance, usb_address_t address, 231 197 usb_endpoint_t endpoint, usb_direction_t direction) … … 278 244 } 279 245 /*----------------------------------------------------------------------------*/ 280 /** Get access to endpoint structures281 *282 * @param[in] instance OHCI hc driver structure.283 * @param[in] address USB address of the device.284 * @param[in] endpoint USB endpoint number.285 * @param[in] direction Direction of the endpoint.286 * @param[out] bw Reserved bandwidth.287 * @return Error code288 */289 246 endpoint_t * hc_get_endpoint(hc_t *instance, usb_address_t address, 290 247 usb_endpoint_t endpoint, usb_direction_t direction, size_t *bw) … … 298 255 } 299 256 /*----------------------------------------------------------------------------*/ 300 /** Add USB transfer to the schedule.301 *302 * @param[in] instance OHCI hc driver structure.303 * @param[in] batch Batch representing the transfer.304 * @return Error code.305 */306 257 int hc_schedule(hc_t *instance, usb_transfer_batch_t *batch) 307 258 { … … 310 261 assert(batch->ep); 311 262 312 /* Check for root hub communication */263 /* check for root hub communication */ 313 264 if (batch->ep->address == instance->rh.address) { 314 265 return rh_request(&instance->rh, batch); … … 318 269 list_append(&batch->link, &instance->pending_batches); 319 270 batch_commit(batch); 320 321 /* Control and bulk schedules need a kick to start working */ 322 switch (batch->ep->transfer_type) 323 { 271 switch (batch->ep->transfer_type) { 324 272 case USB_TRANSFER_CONTROL: 325 273 instance->registers->command_status |= CS_CLF; … … 331 279 break; 332 280 } 281 333 282 fibril_mutex_unlock(&instance->guard); 334 283 return EOK; 335 284 } 336 285 /*----------------------------------------------------------------------------*/ 337 /** Interrupt handling routine338 *339 * @param[in] instance OHCI hc driver structure.340 * @param[in] status Value of the status register at the time of interrupt.341 */342 286 void hc_interrupt(hc_t *instance, uint32_t status) 343 287 { … … 378 322 } 379 323 /*----------------------------------------------------------------------------*/ 380 /** Check status register regularly381 *382 * @param[in] instance OHCI hc driver structure.383 * @return Error code384 */385 324 int interrupt_emulator(hc_t *instance) 386 325 { … … 391 330 instance->registers->interrupt_status = status; 392 331 hc_interrupt(instance, status); 393 async_usleep( 10000);332 async_usleep(50000); 394 333 } 395 334 return EOK; 396 335 } 397 336 /*----------------------------------------------------------------------------*/ 398 /** Turn off any (BIOS)driver that might be in control of the device.399 *400 * @param[in] instance OHCI hc driver structure.401 */402 337 void hc_gain_control(hc_t *instance) 403 338 { … … 449 384 } 450 385 /*----------------------------------------------------------------------------*/ 451 /** OHCI hw initialization routine.452 *453 * @param[in] instance OHCI hc driver structure.454 */455 386 void hc_start_hw(hc_t *instance) 456 387 { … … 520 451 } 521 452 /*----------------------------------------------------------------------------*/ 522 /** Initialize schedule queues523 *524 * @param[in] instance OHCI hc driver structure525 * @return Error code526 */527 453 int hc_init_transfer_lists(hc_t *instance) 528 454 { … … 540 466 endpoint_list_fini(&instance->lists[USB_TRANSFER_BULK]); \ 541 467 } \ 542 return ret; \543 468 } while (0) 544 469 … … 554 479 } 555 480 /*----------------------------------------------------------------------------*/ 556 /** Initialize memory structures used by the OHCI hcd.557 *558 * @param[in] instance OHCI hc driver structure.559 * @return Error code.560 */561 481 int hc_init_memory(hc_t *instance) 562 482 { … … 585 505 /* Init interrupt code */ 586 506 instance->interrupt_code.cmds = instance->interrupt_commands; 587 instance->interrupt_code.cmdcount = OHCI_NEEDED_IRQ_COMMANDS;588 507 { 589 508 /* Read status register */ … … 605 524 instance->interrupt_commands[2].srcarg = 2; 606 525 607 /* Write -clean status register */526 /* Write clean status register */ 608 527 instance->interrupt_commands[3].cmd = CMD_MEM_WRITE_A_32; 609 528 instance->interrupt_commands[3].srcarg = 1; … … 613 532 /* Accept interrupt */ 614 533 instance->interrupt_commands[4].cmd = CMD_ACCEPT; 534 535 instance->interrupt_code.cmdcount = OHCI_NEEDED_IRQ_COMMANDS; 615 536 } 616 537 -
uspace/drv/ohci/hc.h
r98d7550 r17fc40c 53 53 #define OHCI_NEEDED_IRQ_COMMANDS 5 54 54 55 /** Main OHCI drier structure */56 55 typedef struct hc { 57 /** USB bus driver, devices and addresses */58 usb_device_keeper_t manager;59 /** USB bus driver, endpoints */60 usb_endpoint_manager_t ep_manager;61 62 /** Memory mapped I/O registers area */63 56 ohci_regs_t *registers; 64 /** Host controller communication area structure */65 57 hcca_t *hcca; 66 58 67 /** Transfer schedules */ 59 usb_address_t rh_address; 60 rh_t rh; 61 68 62 endpoint_list_t lists[4]; 69 /** List of active transfers */70 63 link_t pending_batches; 71 64 72 /** Fibril for periodic checks if interrupts can't be used */ 65 usb_device_keeper_t manager; 66 usb_endpoint_manager_t ep_manager; 73 67 fid_t interrupt_emulator; 74 75 /** Guards schedule and endpoint manipulation */76 68 fibril_mutex_t guard; 77 69 … … 81 73 /** Commands that form interrupt code */ 82 74 irq_cmd_t interrupt_commands[OHCI_NEEDED_IRQ_COMMANDS]; 83 84 /** USB hub emulation structure */85 rh_t rh;86 75 } hc_t; 87 76 88 77 int hc_register_hub(hc_t *instance, ddf_fun_t *hub_fun); 78 89 79 int hc_init(hc_t *instance, uintptr_t regs, size_t reg_size, bool interrupts); 80 90 81 void hc_start_hw(hc_t *instance); 91 82 … … 94 85 * @param[in] instance Host controller structure to use. 95 86 */ 96 static inline void hc_fini(hc_t *instance) 97 { /* TODO: implement*/ }; 87 static inline void hc_fini(hc_t *instance) { /* TODO: implement*/ }; 98 88 99 89 int hc_add_endpoint(hc_t *instance, usb_address_t address, usb_endpoint_t ep, 100 90 usb_speed_t speed, usb_transfer_type_t type, usb_direction_t direction, 101 91 size_t max_packet_size, size_t size, unsigned interval); 92 102 93 int hc_remove_endpoint(hc_t *instance, usb_address_t address, 103 94 usb_endpoint_t endpoint, usb_direction_t direction); 95 104 96 endpoint_t * hc_get_endpoint(hc_t *instance, usb_address_t address, 105 97 usb_endpoint_t endpoint, usb_direction_t direction, size_t *bw); 106 98 107 99 int hc_schedule(hc_t *instance, usb_transfer_batch_t *batch); 100 108 101 void hc_interrupt(hc_t *instance, uint32_t status); 109 102 … … 114 107 */ 115 108 static inline hc_t * fun_to_hc(ddf_fun_t *fun) 116 { return fun->driver_data; }109 { return (hc_t*)fun->driver_data; } 117 110 #endif 118 111 /** -
uspace/drv/ohci/hcd_endpoint.c
r98d7550 r17fc40c 35 35 #include "hcd_endpoint.h" 36 36 37 /** Callback to set toggle on ED.38 *39 * @param[in] hcd_ep hcd endpoint structure40 * @param[in] toggle new value of toggle bit41 */42 37 static void hcd_ep_toggle_set(void *hcd_ep, int toggle) 43 38 { … … 47 42 ed_toggle_set(instance->ed, toggle); 48 43 } 49 /*----------------------------------------------------------------------------*/50 /** Callback to get value of toggle bit.51 *52 * @param[in] hcd_ep hcd endpoint structure53 * @return Current value of toggle bit.54 */55 44 static int hcd_ep_toggle_get(void *hcd_ep) 56 45 { … … 60 49 return ed_toggle_get(instance->ed); 61 50 } 62 /*----------------------------------------------------------------------------*/ 63 /** Creates new hcd endpoint representation. 64 * 65 * @param[in] ep USBD endpoint structure 66 * @return pointer to a new hcd endpoint structure, NULL on failure. 67 */ 51 52 68 53 hcd_endpoint_t * hcd_endpoint_assign(endpoint_t *ep) 69 54 { … … 93 78 } 94 79 /*----------------------------------------------------------------------------*/ 95 /** Disposes assigned hcd endpoint structure 96 * 97 * @param[in] ep USBD endpoint structure 98 */ 80 hcd_endpoint_t * hcd_endpoint_get(endpoint_t *ep) 81 { 82 assert(ep); 83 return ep->hc_data.data; 84 } 85 /*----------------------------------------------------------------------------*/ 99 86 void hcd_endpoint_clear(endpoint_t *ep) 100 87 { -
uspace/drv/ohci/hcd_endpoint.h
r98d7550 r17fc40c 42 42 #include "hw_struct/transfer_descriptor.h" 43 43 44 /** Connector structure linking ED to to prepared TD. */ 45 typedef struct hcd_endpoint { 46 /** OHCI endpoint descriptor */ 44 typedef struct hcd_endpoint 45 { 47 46 ed_t *ed; 48 /** Currently enqueued transfer descriptor */49 47 td_t *td; 50 /** Linked list used by driver software */51 48 link_t link; 52 49 } hcd_endpoint_t; 53 50 54 51 hcd_endpoint_t * hcd_endpoint_assign(endpoint_t *ep); 52 53 hcd_endpoint_t * hcd_endpoint_get(endpoint_t *ep); 54 55 55 void hcd_endpoint_clear(endpoint_t *ep); 56 57 /** Get and convert assigned hcd_endpoint_t structure58 * @param[in] ep USBD endpoint structure.59 * @return Pointer to assigned hcd endpoint structure60 */61 static inline hcd_endpoint_t * hcd_endpoint_get(endpoint_t *ep)62 {63 assert(ep);64 return ep->hc_data.data;65 }66 67 56 #endif 68 57 /** -
uspace/drv/ohci/ohci_regs.h
r98d7550 r17fc40c 36 36 #include <stdint.h> 37 37 38 /** OHCI memory mapped registers structure */ 39 typedef struct ohci_regs{38 typedef struct ohci_regs 39 { 40 40 const volatile uint32_t revision; 41 41 volatile uint32_t control; -
uspace/drv/uhci-hcd/batch.c
r98d7550 r17fc40c 95 95 */ 96 96 usb_transfer_batch_t * batch_get(ddf_fun_t *fun, endpoint_t *ep, 97 char *buffer, size_t buffer_size, 98 const char* setup_buffer, size_t setup_size, 97 char *buffer, size_t buffer_size, char* setup_buffer, size_t setup_size, 99 98 usbhc_iface_transfer_in_callback_t func_in, 100 99 usbhc_iface_transfer_out_callback_t func_out, void *arg) -
uspace/drv/uhci-hcd/batch.h
r98d7550 r17fc40c 45 45 usb_transfer_batch_t * batch_get( 46 46 ddf_fun_t *fun, endpoint_t *ep, char *buffer, size_t size, 47 c onst char *setup_buffer, size_t setup_size,47 char *setup_buffer, size_t setup_size, 48 48 usbhc_iface_transfer_in_callback_t func_in, 49 49 usbhc_iface_transfer_out_callback_t func_out, … … 55 55 56 56 void batch_control_write(usb_transfer_batch_t *instance); 57 57 58 void batch_control_read(usb_transfer_batch_t *instance); 58 59 59 60 void batch_interrupt_in(usb_transfer_batch_t *instance); 61 60 62 void batch_interrupt_out(usb_transfer_batch_t *instance); 61 63 62 64 void batch_bulk_in(usb_transfer_batch_t *instance); 65 63 66 void batch_bulk_out(usb_transfer_batch_t *instance); 64 67 -
uspace/drv/uhci-hcd/hc.c
r98d7550 r17fc40c 57 57 static int hc_debug_checker(void *arg); 58 58 /*----------------------------------------------------------------------------*/ 59 /** Initialize UHCI hc driver structure59 /** Initialize UHCI hcd driver structure 60 60 * 61 61 * @param[in] instance Memory place to initialize. -
uspace/drv/uhci-hcd/hc.h
r98d7550 r17fc40c 95 95 #define UHCI_NEEDED_IRQ_COMMANDS 5 96 96 97 /* * Main UHCIdriver structure */97 /* Main HC driver structure */ 98 98 typedef struct hc { 99 99 /** USB bus driver, devices and addresses */ -
uspace/drv/uhci-hcd/transfer_list.h
r98d7550 r17fc40c 43 43 * of currently executed transfers 44 44 */ 45 typedef struct transfer_list { 45 typedef struct transfer_list 46 { 46 47 /** Guard against multiple add/remove races */ 47 48 fibril_mutex_t guard;
Note:
See TracChangeset
for help on using the changeset viewer.