Changeset 68e5406 in mainline
- Timestamp:
- 2017-12-10T21:08:11Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 4c6de4f
- Parents:
- dd8ab1c
- Location:
- uspace
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/ehci/hc.c
rdd8ab1c r68e5406 96 96 * @param[in] hw_res Device's resources. 97 97 * 98 * @param[out] irq 99 * 98 100 * @return Error code. 99 101 */ 100 int ehci_hc_gen_irq_code(irq_code_t *code, const hw_res_list_parsed_t *hw_res )102 int ehci_hc_gen_irq_code(irq_code_t *code, const hw_res_list_parsed_t *hw_res, int *irq) 101 103 { 102 104 assert(code); … … 146 148 RNGABSPTR(regs), RNGSZ(regs), hw_res->irqs.irqs[0]); 147 149 148 return hw_res->irqs.irqs[0]; 150 *irq = hw_res->irqs.irqs[0]; 151 return EOK; 149 152 } 150 153 -
uspace/drv/bus/usb/ehci/hc.h
rdd8ab1c r68e5406 88 88 void hc_dequeue_endpoint(hc_t *instance, const endpoint_t *ep); 89 89 90 int ehci_hc_gen_irq_code(irq_code_t *code, const hw_res_list_parsed_t *hw_res );90 int ehci_hc_gen_irq_code(irq_code_t *code, const hw_res_list_parsed_t *hw_res, int *irq); 91 91 92 92 void ehci_hc_interrupt(hcd_t *hcd, uint32_t status); -
uspace/drv/bus/usb/ohci/hc.c
rdd8ab1c r68e5406 103 103 * @return Error code. 104 104 */ 105 int ohci_hc_gen_irq_code(irq_code_t *code, const hw_res_list_parsed_t *hw_res )105 int ohci_hc_gen_irq_code(irq_code_t *code, const hw_res_list_parsed_t *hw_res, int *irq) 106 106 { 107 107 assert(code); … … 141 141 RNGABSPTR(regs), RNGSZ(regs), hw_res->irqs.irqs[0]); 142 142 143 return hw_res->irqs.irqs[0]; 143 *irq = hw_res->irqs.irqs[0]; 144 return EOK; 144 145 } 145 146 -
uspace/drv/bus/usb/ohci/hc.h
rdd8ab1c r68e5406 86 86 extern void hc_dequeue_endpoint(hc_t *, const endpoint_t *); 87 87 88 int ohci_hc_gen_irq_code(irq_code_t *code, const hw_res_list_parsed_t *hw_res );88 int ohci_hc_gen_irq_code(irq_code_t *code, const hw_res_list_parsed_t *hw_res, int *irq); 89 89 90 90 extern void ohci_hc_interrupt(hcd_t *, uint32_t); -
uspace/drv/bus/usb/uhci/hc.c
rdd8ab1c r68e5406 103 103 * @param[out] code IRQ code structure. 104 104 * @param[in] hw_res Device's resources. 105 * @param[out] irq 105 106 * 106 107 * @return Error code. 107 108 */ 108 int uhci_hc_gen_irq_code(irq_code_t *code, const hw_res_list_parsed_t *hw_res )109 int uhci_hc_gen_irq_code(irq_code_t *code, const hw_res_list_parsed_t *hw_res, int *irq) 109 110 { 110 111 assert(code); … … 142 143 RNGABSPTR(regs), RNGSZ(regs), hw_res->irqs.irqs[0]); 143 144 144 return hw_res->irqs.irqs[0]; 145 *irq = hw_res->irqs.irqs[0]; 146 return EOK; 145 147 } 146 148 -
uspace/drv/bus/usb/uhci/hc.h
rdd8ab1c r68e5406 127 127 extern void hc_fini(hc_t *); 128 128 129 extern int uhci_hc_gen_irq_code(irq_code_t *, const hw_res_list_parsed_t * );129 extern int uhci_hc_gen_irq_code(irq_code_t *, const hw_res_list_parsed_t *, int *); 130 130 131 131 extern void uhci_hc_interrupt(hcd_t *, uint32_t); -
uspace/lib/usbhost/include/usb/host/ddf_helpers.h
rdd8ab1c r68e5406 48 48 typedef void (*driver_fini_t)(hcd_t *); 49 49 typedef int (*claim_t)(ddf_dev_t *); 50 typedef int (*irq_code_gen_t)(irq_code_t *, const hw_res_list_parsed_t * );50 typedef int (*irq_code_gen_t)(irq_code_t *, const hw_res_list_parsed_t *, int *); 51 51 52 52 typedef struct { … … 75 75 const hw_res_list_parsed_t *hw_res, 76 76 interrupt_handler_t handler, 77 int (*gen_irq_code)(irq_code_t *, const hw_res_list_parsed_t * ),77 int (*gen_irq_code)(irq_code_t *, const hw_res_list_parsed_t *, int *), 78 78 cap_handle_t *handle); 79 79 void ddf_hcd_gen_irq_handler(ipc_call_t *call, ddf_dev_t *dev); -
uspace/lib/usbhost/include/usb/host/hcd.h
rdd8ab1c r68e5406 102 102 } 103 103 104 extern usb_address_t hcd_request_address(hcd_t *, usb_speed_t);104 extern int hcd_request_address(hcd_t *, usb_speed_t, usb_address_t *); 105 105 106 106 extern int hcd_release_address(hcd_t *, usb_address_t); … … 123 123 usbhc_iface_transfer_out_callback_t, void *, const char *); 124 124 125 extern ssize_t hcd_send_batch_sync(hcd_t *, usb_target_t, usb_direction_t,126 void *, size_t, uint64_t, const char * );125 extern int hcd_send_batch_sync(hcd_t *, usb_target_t, usb_direction_t, 126 void *, size_t, uint64_t, const char *, size_t *); 127 127 128 128 #endif -
uspace/lib/usbhost/src/ddf_helpers.c
rdd8ab1c r68e5406 481 481 }}; 482 482 483 const usb_address_t address = hcd_request_address(hcd, speed); 484 if (address < 0) { 483 usb_address_t address; 484 ret = hcd_request_address(hcd, speed, &address); 485 if (ret != EOK) { 485 486 usb_log_error("Failed to reserve new address: %s.", 486 str_error( address));487 return address;487 str_error(ret)); 488 return ret; 488 489 } 489 490 … … 518 519 usb_log_debug("Device(%d): Requesting first 8B of device descriptor.", 519 520 address); 520 ssize_t got = hcd_send_batch_sync(hcd, default_target, USB_DIRECTION_IN, 521 size_t got; 522 ret = hcd_send_batch_sync(hcd, default_target, USB_DIRECTION_IN, 521 523 &desc, CTRL_PIPE_MIN_PACKET_SIZE, *(uint64_t *)&get_device_desc_8, 522 "read first 8 bytes of dev descriptor"); 523 524 if (got != CTRL_PIPE_MIN_PACKET_SIZE) { 525 ret = got < 0 ? got : EOVERFLOW; 524 "read first 8 bytes of dev descriptor", &got); 525 526 if (ret == EOK && got != CTRL_PIPE_MIN_PACKET_SIZE) { 527 ret = EOVERFLOW; 528 } 529 530 if (ret != EOK) { 526 531 usb_log_error("Device(%d): Failed to get 8B of dev descr: %s.", 527 532 address, str_error(ret)); … … 552 557 553 558 usb_log_debug("Device(%d): Setting USB address.", address); 554 got = hcd_send_batch_sync(hcd, default_target, USB_DIRECTION_OUT,555 NULL, 0, *(uint64_t *)&set_address, "set address" );559 ret = hcd_send_batch_sync(hcd, default_target, USB_DIRECTION_OUT, 560 NULL, 0, *(uint64_t *)&set_address, "set address", &got); 556 561 557 562 usb_log_debug("Device(%d): Removing default (0:0) EP.", address); 558 563 hcd_remove_ep(hcd, default_target, USB_DIRECTION_BOTH); 559 564 560 if ( got != 0) {565 if (ret != EOK) { 561 566 usb_log_error("Device(%d): Failed to set new address: %s.", 562 address, str_error( got));567 address, str_error(ret)); 563 568 hcd_remove_ep(hcd, target, USB_DIRECTION_BOTH); 564 569 hcd_release_address(hcd, address); 565 return got;570 return ret; 566 571 } 567 572 … … 572 577 usb_log_debug("Device(%d): Requesting full device descriptor.", 573 578 address); 574 got = hcd_send_batch_sync(hcd, target, USB_DIRECTION_IN,579 ret = hcd_send_batch_sync(hcd, target, USB_DIRECTION_IN, 575 580 &desc, sizeof(desc), *(uint64_t *)&get_device_desc, 576 "read device descriptor" );581 "read device descriptor", &got); 577 582 if (ret != EOK) { 578 583 usb_log_error("Device(%d): Failed to set get dev descriptor: %s", … … 749 754 const hw_res_list_parsed_t *hw_res, 750 755 interrupt_handler_t handler, 751 int (*gen_irq_code)(irq_code_t *, const hw_res_list_parsed_t * hw_res),756 int (*gen_irq_code)(irq_code_t *, const hw_res_list_parsed_t *, int *), 752 757 cap_handle_t *handle) 753 758 { … … 759 764 irq_code_t irq_code = {0}; 760 765 761 const int irq = gen_irq_code(&irq_code, hw_res); 762 if (irq < 0) { 766 int irq; 767 int ret = gen_irq_code(&irq_code, hw_res, &irq); 768 if (ret != EOK) { 763 769 usb_log_error("Failed to generate IRQ code: %s.\n", 764 str_error( irq));765 return irq;770 str_error(ret)); 771 return ret; 766 772 } 767 773 768 774 /* Register handler to avoid interrupt lockup */ 769 intret = register_interrupt_handler(device, irq, handler,775 ret = register_interrupt_handler(device, irq, handler, 770 776 &irq_code, handle); 771 777 irq_code_clean(&irq_code); -
uspace/lib/usbhost/src/hcd.c
rdd8ab1c r68e5406 102 102 } 103 103 104 usb_address_t hcd_request_address(hcd_t *hcd, usb_speed_t speed) 105 { 106 assert(hcd); 107 usb_address_t address = 0; 108 const int ret = usb_bus_request_address( 109 &hcd->bus, &address, false, speed); 110 if (ret != EOK) 111 return ret; 112 return address; 104 int hcd_request_address(hcd_t *hcd, usb_speed_t speed, usb_address_t *address) 105 { 106 assert(hcd); 107 return usb_bus_request_address(&hcd->bus, address, false, speed); 113 108 } 114 109 … … 271 266 272 267 /** this is really ugly version of sync usb communication */ 273 ssize_t hcd_send_batch_sync(268 int hcd_send_batch_sync( 274 269 hcd_t *hcd, usb_target_t target, usb_direction_t dir, 275 void *data, size_t size, uint64_t setup_data, const char* name )270 void *data, size_t size, uint64_t setup_data, const char* name, size_t *out_size) 276 271 { 277 272 assert(hcd); … … 289 284 290 285 if (sd.ret == EOK) 291 returnsd.size;286 *out_size = sd.size; 292 287 return sd.ret; 293 288 }
Note:
See TracChangeset
for help on using the changeset viewer.