Changes in uspace/drv/bus/usb/uhci/hc.c [d930980:8486c07] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/uhci/hc.c
rd930980 r8486c07 35 35 #include <str_error.h> 36 36 #include <adt/list.h> 37 #include < ddi.h>37 #include <libarch/ddi.h> 38 38 39 39 #include <usb/debug.h> … … 90 90 static int hc_debug_checker(void *arg); 91 91 92 enum { 93 /** Number of PIO ranges used in IRQ code */ 94 hc_irq_pio_range_count = 95 sizeof(uhci_irq_pio_ranges) / sizeof(irq_pio_range_t), 96 97 /* Number of commands used in IRQ code */ 98 hc_irq_cmd_count = 99 sizeof(uhci_irq_commands) / sizeof(irq_cmd_t) 100 }; 92 93 /** Get number of PIO ranges used in IRQ code. 94 * @return Number of ranges. 95 */ 96 size_t hc_irq_pio_range_count(void) 97 { 98 return sizeof(uhci_irq_pio_ranges) / sizeof(irq_pio_range_t); 99 } 100 101 /** Get number of commands used in IRQ code. 102 * @return Number of commands. 103 */ 104 size_t hc_irq_cmd_count(void) 105 { 106 return sizeof(uhci_irq_commands) / sizeof(irq_cmd_t); 107 } 101 108 102 109 /** Generate IRQ code. … … 126 133 cmds[0].addr = ®isters->usbsts; 127 134 cmds[3].addr = ®isters->usbsts; 128 129 return EOK;130 }131 132 /** Register interrupt handler.133 *134 * @param[in] device Host controller DDF device135 * @param[in] reg_base Register range base136 * @param[in] reg_size Register range size137 * @param[in] irq Interrupt number138 * @paran[in] handler Interrupt handler139 *140 * @return EOK on success or negative error code141 */142 int hc_register_irq_handler(ddf_dev_t *device, uintptr_t reg_base, size_t reg_size,143 int irq, interrupt_handler_t handler)144 {145 int rc;146 irq_pio_range_t irq_ranges[hc_irq_pio_range_count];147 irq_cmd_t irq_cmds[hc_irq_cmd_count];148 rc = hc_get_irq_code(irq_ranges, sizeof(irq_ranges), irq_cmds,149 sizeof(irq_cmds), reg_base, reg_size);150 if (rc != EOK) {151 usb_log_error("Failed to generate IRQ commands: %s.\n",152 str_error(rc));153 return rc;154 }155 156 irq_code_t irq_code = {157 .rangecount = hc_irq_pio_range_count,158 .ranges = irq_ranges,159 .cmdcount = hc_irq_cmd_count,160 .cmds = irq_cmds161 };162 163 /* Register handler to avoid interrupt lockup */164 rc = register_interrupt_handler(device, irq, handler, &irq_code);165 if (rc != EOK) {166 usb_log_error("Failed to register interrupt handler: %s.\n",167 str_error(rc));168 return rc;169 }170 135 171 136 return EOK; … … 244 209 { 245 210 assert(reg_size >= sizeof(uhci_regs_t)); 246 int rc; 211 int ret; 212 213 #define CHECK_RET_RETURN(ret, message...) \ 214 if (ret != EOK) { \ 215 usb_log_error(message); \ 216 return ret; \ 217 } else (void) 0 247 218 248 219 instance->hw_interrupts = interrupts; … … 251 222 /* allow access to hc control registers */ 252 223 uhci_regs_t *io; 253 rc = pio_enable(regs, reg_size, (void **)&io); 254 if (rc != EOK) { 255 usb_log_error("Failed to gain access to registers at %p: %s.\n", 256 io, str_error(rc)); 257 return rc; 258 } 259 224 ret = pio_enable(regs, reg_size, (void **)&io); 225 CHECK_RET_RETURN(ret, "Failed to gain access to registers at %p: %s.\n", 226 io, str_error(ret)); 260 227 instance->registers = io; 261 228 usb_log_debug( 262 229 "Device registers at %p (%zuB) accessible.\n", io, reg_size); 263 230 264 r c= hc_init_mem_structures(instance);265 if (rc != EOK) {266 usb_log_error("Failed to initialize UHCI memory structures: %s.\n",267 str_error(rc));268 return rc; 269 } 231 ret = hc_init_mem_structures(instance); 232 CHECK_RET_RETURN(ret, 233 "Failed to initialize UHCI memory structures: %s.\n", 234 str_error(ret)); 235 236 #undef CHECK_RET_RETURN 270 237 271 238 hcd_init(&instance->generic, USB_SPEED_FULL, … … 430 397 431 398 return EOK; 399 #undef CHECK_RET_CLEAR_RETURN 432 400 } 433 401
Note:
See TracChangeset
for help on using the changeset viewer.