Changeset ba4a03a5 in mainline
- Timestamp:
- 2013-12-31T23:11:00Z (11 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- d1df381
- Parents:
- e3a07bba
- Location:
- uspace
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/ehci/ehci.c
re3a07bba rba4a03a5 96 96 addr_range_t regs = hw_res.mem_ranges.ranges[0]; 97 97 const int irq = hw_res.irqs.irqs[0]; 98 hw_res_list_parsed_clean(&hw_res);99 100 usb_log_debug("Memory mapped regs at %p (size %zu), IRQ %d.\n",101 RNGABSPTR(regs), RNGSZ(regs), irq);102 98 103 99 /* Initialize generic HCD driver */ … … 107 103 usb_log_error("Failed to setup generic hcd structures: %s.", 108 104 str_error(ret)); 105 hw_res_list_parsed_clean(&hw_res); 109 106 return ret; 110 107 } … … 113 110 if (!hc) { 114 111 usb_log_error("Failed to allocate driver structure.\n"); 112 hw_res_list_parsed_clean(&hw_res); 115 113 ret = ENOMEM; 116 114 goto ddf_hc_clean; … … 119 117 /* Try to enable interrupts */ 120 118 bool interrupts = false; 121 ret = hcd_ddf_setup_interrupts(device, & regs, irq, irq_handler,119 ret = hcd_ddf_setup_interrupts(device, &hw_res, irq_handler, 122 120 hc_gen_irq_code); 123 121 if (ret != EOK) { … … 131 129 /* Initialize EHCI HC */ 132 130 ret = hc_init(hc, ®s, interrupts); 131 hw_res_list_parsed_clean(&hw_res); 133 132 if (ret != EOK) { 134 133 usb_log_error("Failed to init hc: %s.\n", str_error(ret)); -
uspace/drv/bus/usb/ehci/hc.c
re3a07bba rba4a03a5 99 99 * @param[out] cmds Commands buffer. 100 100 * @param[in] cmds_size Size of the commands buffer (bytes). 101 * @param[in] regs Device's register range.101 * @param[in] hw_res Device's resources. 102 102 * 103 103 * @return Error code. 104 104 */ 105 int hc_gen_irq_code(irq_code_t *code, addr_range_t *regs)105 int hc_gen_irq_code(irq_code_t *code, const hw_res_list_parsed_t *hw_res) 106 106 { 107 107 assert(code); 108 if (RNGSZ(*regs) < sizeof(ehci_regs_t)) 108 assert(hw_res); 109 110 if (hw_res->irqs.count != 1 || hw_res->mem_ranges.count != 1) 111 return EINVAL; 112 113 addr_range_t regs = hw_res->mem_ranges.ranges[0]; 114 115 if (RNGSZ(regs) < sizeof(ehci_regs_t)) 109 116 return EOVERFLOW; 110 117 … … 123 130 124 131 memcpy(code->ranges, ehci_pio_ranges, sizeof(ehci_pio_ranges)); 125 code->ranges[0].base = RNGABS( *regs);132 code->ranges[0].base = RNGABS(regs); 126 133 127 134 memcpy(code->cmds, ehci_irq_commands, sizeof(ehci_irq_commands)); 128 135 ehci_caps_regs_t *caps = NULL; 129 int ret = pio_enable_range( regs, (void**)&caps);136 int ret = pio_enable_range(®s, (void**)&caps); 130 137 if (ret != EOK) { 131 138 return ret; 132 139 } 133 140 ehci_regs_t *registers = 134 (ehci_regs_t *)(RNGABSPTR( *regs) + EHCI_RD8(caps->caplength));141 (ehci_regs_t *)(RNGABSPTR(regs) + EHCI_RD8(caps->caplength)); 135 142 code->cmds[0].addr = (void *) ®isters->usbsts; 136 143 code->cmds[3].addr = (void *) ®isters->usbsts; 137 144 EHCI_WR(code->cmds[1].value, EHCI_USED_INTERRUPTS); 138 145 139 return EOK; 146 usb_log_debug("Memory mapped regs at %p (size %zu), IRQ %d.\n", 147 RNGABSPTR(regs), RNGSZ(regs), hw_res->irqs.irqs[0]); 148 149 return hw_res->irqs.irqs[0]; 140 150 } 141 151 -
uspace/drv/bus/usb/ehci/hc.h
re3a07bba rba4a03a5 74 74 } hc_t; 75 75 76 int hc_gen_irq_code(irq_code_t *code, addr_range_t *regs);76 int hc_gen_irq_code(irq_code_t *code, const hw_res_list_parsed_t *hw_res); 77 77 int hc_register_hub(hc_t *instance, ddf_fun_t *hub_fun); 78 78 int hc_init(hc_t *instance, addr_range_t *regs, bool interrupts); -
uspace/drv/bus/usb/ohci/hc.c
re3a07bba rba4a03a5 100 100 * @param[out] cmds Commands buffer. 101 101 * @param[in] cmds_size Size of the commands buffer (bytes). 102 * @param[in] regs Device's register range.102 * @param[in] hw_res Device's resources. 103 103 * 104 104 * @return Error code. 105 105 */ 106 int hc_gen_irq_code(irq_code_t *code, addr_range_t *regs)106 int hc_gen_irq_code(irq_code_t *code, const hw_res_list_parsed_t *hw_res) 107 107 { 108 108 assert(code); 109 if (RNGSZ(*regs) < sizeof(ohci_regs_t)) 109 assert(hw_res); 110 111 if (hw_res->irqs.count != 1 || hw_res->mem_ranges.count != 1) 112 return EINVAL; 113 114 const addr_range_t regs = hw_res->mem_ranges.ranges[0]; 115 116 if (RNGSZ(regs) < sizeof(ohci_regs_t)) 110 117 return EOVERFLOW; 111 118 … … 124 131 125 132 memcpy(code->ranges, ohci_pio_ranges, sizeof(ohci_pio_ranges)); 126 code->ranges[0].base = RNGABS( *regs);133 code->ranges[0].base = RNGABS(regs); 127 134 128 135 memcpy(code->cmds, ohci_irq_commands, sizeof(ohci_irq_commands)); 129 ohci_regs_t *registers = (ohci_regs_t *) RNGABSPTR( *regs);136 ohci_regs_t *registers = (ohci_regs_t *) RNGABSPTR(regs); 130 137 code->cmds[0].addr = (void *) ®isters->interrupt_status; 131 138 code->cmds[3].addr = (void *) ®isters->interrupt_status; 132 139 OHCI_WR(code->cmds[1].value, OHCI_USED_INTERRUPTS); 133 140 134 return EOK; 141 usb_log_debug("Memory mapped regs at %p (size %zu), IRQ %d.\n", 142 RNGABSPTR(regs), RNGSZ(regs), hw_res->irqs.irqs[0]); 143 144 return hw_res->irqs.irqs[0]; 135 145 } 136 146 -
uspace/drv/bus/usb/ohci/hc.h
re3a07bba rba4a03a5 75 75 } hc_t; 76 76 77 int hc_gen_irq_code(irq_code_t *code, addr_range_t *regs);77 int hc_gen_irq_code(irq_code_t *code, const hw_res_list_parsed_t *hw_res); 78 78 int hc_register_hub(hc_t *instance, ddf_fun_t *hub_fun); 79 79 int hc_init(hc_t *instance, addr_range_t *regs, bool interrupts); -
uspace/drv/bus/usb/ohci/ohci.c
re3a07bba rba4a03a5 96 96 addr_range_t regs = hw_res.mem_ranges.ranges[0]; 97 97 const int irq = hw_res.irqs.irqs[0]; 98 hw_res_list_parsed_clean(&hw_res);99 100 usb_log_debug("Memory mapped regs at %p (size %zu), IRQ %d.\n",101 RNGABSPTR(regs), RNGSZ(regs), irq);102 98 103 99 /* Initialize generic HCD driver */ … … 105 101 BANDWIDTH_AVAILABLE_USB11, bandwidth_count_usb11); 106 102 if (ret != EOK) { 103 hw_res_list_parsed_clean(&hw_res); 107 104 usb_log_error("Failed to setup generic hcd structures: %s.", 108 105 str_error(ret)); … … 113 110 if (!hc) { 114 111 usb_log_error("Failed to allocate driver structure.\n"); 112 hw_res_list_parsed_clean(&hw_res); 115 113 ret = ENOMEM; 116 114 goto ddf_hc_clean; … … 119 117 /* Try to enable interrupts */ 120 118 bool interrupts = false; 121 ret = hcd_ddf_setup_interrupts(device, & regs, irq, irq_handler,119 ret = hcd_ddf_setup_interrupts(device, &hw_res, irq_handler, 122 120 hc_gen_irq_code); 123 121 if (ret != EOK) { … … 131 129 /* Initialize OHCI HC */ 132 130 ret = hc_init(hc, ®s, interrupts); 131 hw_res_list_parsed_clean(&hw_res); 133 132 if (ret != EOK) { 134 133 usb_log_error("Failed to init hc: %s.\n", str_error(ret)); -
uspace/drv/bus/usb/uhci/hc.c
re3a07bba rba4a03a5 102 102 /** Generate IRQ code. 103 103 * @param[out] code IRQ code structure. 104 * @param[in] regs Device's register range.104 * @param[in] hw_res Device's resources. 105 105 * 106 106 * @return Error code. 107 107 */ 108 int hc_gen_irq_code(irq_code_t *code, addr_range_t *regs)108 int hc_gen_irq_code(irq_code_t *code, const hw_res_list_parsed_t *hw_res) 109 109 { 110 110 assert(code); 111 112 if (RNGSZ(*regs) < sizeof(uhci_regs_t)) 111 assert(hw_res); 112 113 if (hw_res->irqs.count != 1 || hw_res->io_ranges.count != 1) 114 return EINVAL; 115 const addr_range_t regs = hw_res->io_ranges.ranges[0]; 116 117 if (RNGSZ(regs) < sizeof(uhci_regs_t)) 113 118 return EOVERFLOW; 114 119 … … 127 132 128 133 memcpy(code->ranges, uhci_irq_pio_ranges, sizeof(uhci_irq_pio_ranges)); 129 code->ranges[0].base = RNGABS( *regs);134 code->ranges[0].base = RNGABS(regs); 130 135 131 136 memcpy(code->cmds, uhci_irq_commands, sizeof(uhci_irq_commands)); 132 uhci_regs_t *registers = (uhci_regs_t *) RNGABSPTR( *regs);137 uhci_regs_t *registers = (uhci_regs_t *) RNGABSPTR(regs); 133 138 code->cmds[0].addr = (void*)®isters->usbsts; 134 139 code->cmds[3].addr = (void*)®isters->usbsts; 135 140 136 return EOK; 141 usb_log_debug("I/O regs at %p (size %zu), IRQ %d.\n", 142 RNGABSPTR(regs), RNGSZ(regs), hw_res->irqs.irqs[0]); 143 144 return hw_res->irqs.irqs[0]; 137 145 } 138 146 -
uspace/drv/bus/usb/uhci/hc.h
re3a07bba rba4a03a5 127 127 } hc_t; 128 128 129 int hc_gen_irq_code(irq_code_t *code, addr_range_t *regs);129 int hc_gen_irq_code(irq_code_t *code, const hw_res_list_parsed_t *hw_res); 130 130 void hc_interrupt(hc_t *instance, uint16_t status); 131 131 int hc_init(hc_t *instance, addr_range_t *regs, bool interupts); -
uspace/drv/bus/usb/uhci/uhci.c
re3a07bba rba4a03a5 98 98 addr_range_t regs = hw_res.io_ranges.ranges[0]; 99 99 const int irq = hw_res.irqs.irqs[0]; 100 hw_res_list_parsed_clean(&hw_res);101 102 usb_log_debug("I/O regs at %p (size %zu), IRQ %d.\n",103 RNGABSPTR(regs), RNGSZ(regs), irq);104 100 105 101 ret = hcd_ddf_setup_hc(device, USB_SPEED_FULL, … … 107 103 if (ret != EOK) { 108 104 usb_log_error("Failed to setup generic HCD.\n"); 105 hw_res_list_parsed_clean(&hw_res); 109 106 return ret; 110 107 } … … 113 110 if (!hc) { 114 111 usb_log_error("Failed to allocate UHCI HC structure.\n"); 112 hw_res_list_parsed_clean(&hw_res); 115 113 ret = ENOMEM; 116 114 goto ddf_hc_clean; … … 118 116 119 117 bool interrupts = false; 120 ret = hcd_ddf_setup_interrupts(device, & regs, irq, irq_handler,118 ret = hcd_ddf_setup_interrupts(device, &hw_res, irq_handler, 121 119 hc_gen_irq_code); 122 120 if (ret != EOK) { … … 129 127 130 128 ret = hc_init(hc, ®s, interrupts); 129 hw_res_list_parsed_clean(&hw_res); 131 130 if (ret != EOK) { 132 131 usb_log_error("Failed to init uhci_hcd: %s.\n", str_error(ret)); -
uspace/lib/usbhost/include/usb/host/ddf_helpers.h
re3a07bba rba4a03a5 54 54 int hcd_ddf_enable_interrupts(ddf_dev_t *device); 55 55 int hcd_ddf_get_registers(ddf_dev_t *device, hw_res_list_parsed_t *hw_res); 56 int hcd_ddf_setup_interrupts(ddf_dev_t *device, addr_range_t *regs, int irq, 57 interrupt_handler_t handler, int (*gen_irq_code)(irq_code_t *, addr_range_t *)); 56 int hcd_ddf_setup_interrupts(ddf_dev_t *device, 57 const hw_res_list_parsed_t *hw_res, 58 interrupt_handler_t handler, 59 int (*gen_irq_code)(irq_code_t *, const hw_res_list_parsed_t *)); 58 60 59 61 #endif -
uspace/lib/usbhost/src/ddf_helpers.c
re3a07bba rba4a03a5 712 712 * @return EOK on success or negative error code 713 713 */ 714 int hcd_ddf_setup_interrupts(ddf_dev_t *device, addr_range_t *regs, int irq, 714 int hcd_ddf_setup_interrupts(ddf_dev_t *device, 715 const hw_res_list_parsed_t *hw_res, 715 716 interrupt_handler_t handler, 716 int (*gen_irq_code)(irq_code_t *, addr_range_t *))717 int (*gen_irq_code)(irq_code_t *, const hw_res_list_parsed_t *hw_res)) 717 718 { 718 719 719 720 assert(device); 720 assert( regs);721 assert(hw_res); 721 722 assert(handler); 722 723 assert(gen_irq_code); 723 724 724 725 725 irq_code_t irq_code = {0}; 726 726 727 int ret = gen_irq_code(&irq_code, regs);728 if ( ret != EOK) {727 int irq = gen_irq_code(&irq_code, hw_res); 728 if (irq < 0) { 729 729 usb_log_error("Failed to generate IRQ code: %s.\n", 730 str_error( ret));731 return ret;730 str_error(irq)); 731 return irq; 732 732 } 733 733 734 734 /* Register handler to avoid interrupt lockup */ 735 ret = register_interrupt_handler(device, irq, handler, &irq_code);735 int ret = register_interrupt_handler(device, irq, handler, &irq_code); 736 736 irq_code_clean(&irq_code); 737 737 if (ret != EOK) {
Note:
See TracChangeset
for help on using the changeset viewer.